Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewards Greaselion - Twitter #6671

Merged
merged 3 commits into from
Oct 5, 2020
Merged

Rewards Greaselion - Twitter #6671

merged 3 commits into from
Oct 5, 2020

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Sep 21, 2020

Resolves brave/brave-browser#11462
Resolves brave/brave-browser#6762
Resolves brave/brave-browser#5685
Resolves brave/brave-browser#4557
Resolves brave/brave-browser#8265

Associated Greaselion script PR: brave/brave-site-specific-scripts#16

Submitter Checklist:

Test Plan:

Note: In order to test this PR, you must manually install the Twitter Greaselion script at the moment. This involves pulling down this branch and running the following commands (the example is Windows specific, it will need to be modified slightly for Mac/Linux):

npm run build
cp -R dist/Greaselion.json /c/Users/$USERNAME/AppData/Local/BraveSoftware/Brave-Browser/User\ Data/afalakplffnnnlkncjhbmahjfjhmlkal/1.0.28/1/
cp -R dist/scripts /c/Users/$USERNAME/AppData/Local/BraveSoftware/Brave-Browser/User\ Data/afalakplffnnnlkncjhbmahjfjhmlkal/1.0.28/1/

Desktop

Standard URL

  • Clean profile
  • Run browser
  • Install Twitter Greaselion script as explained above
  • Restart browser
  • Visit a Twitter URL (e.g., https://twitter.com/emerick)
  • Verify that correct publisher information appears in Rewards panel
  • Verify that tipping works as expected
  • Verify that verified checkmark appears in Rewards icon for verified publishers

Excluded URL

  • Clean profile
  • Run browser
  • Install Twitter Greaselion script as explained above
  • Restart browser
  • Visit an excluded Twitter URL (e.g., https://twitter.com/settings)
  • Verify that correct publisher information appears in Rewards panel (twitter.com)
  • Verify that tipping works as expected

Activity

  • Clean profile
  • Run browser
  • Install Twitter Greaselion script as explained above
  • Restart browser
  • Visit a Twitter URL (e.g., https://twitter.com/emerick)
  • Verify that activity_info database table is updated as expected
  • Verify that auto-contribute table is updated to reflect new activity

History

  • Navigate to various Twitter URLs in the same tab
  • Verify that appropriate publisher information appears in the panel
  • Verify that back/forward navigation updates the panel with correct publisher info

Tab Activation

  • Navigate to various Twitter URLs in multiple tabs
  • Verify that appropriate publisher information appears in the panel
  • Verify that switching between tabs updates the panel with correct publisher info

Tipping non-Twitter Publishers

  • Verify that tipping works as expected on non-Twitter publishers (we only made changes to Twitter and only on desktop)
  • Verify that the panel looks as expected on non-Twitter publishers

Mobile

No changes were made to mobile platforms, so verify that Twitter navigation / tipping / Rewards panel continue to work as expected on those platforms.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@emerick emerick requested a review from NejcZdovc as a code owner September 21, 2020 16:39
@emerick emerick self-assigned this Sep 21, 2020
@emerick emerick changed the title Support inline tipping in Twitter via Greaselion Rewards Greaselion - Twitter Sep 21, 2020
@emerick emerick marked this pull request as draft September 21, 2020 16:41
@emerick emerick force-pushed the rewards-greaselion-twitter branch 3 times, most recently from 72fcb96 to 6358b07 Compare September 24, 2020 02:20
@emerick emerick force-pushed the rewards-greaselion-twitter branch 2 times, most recently from 76f156c to 84c283f Compare September 24, 2020 18:49
@emerick emerick requested a review from zenparsing September 24, 2020 23:45
@emerick emerick marked this pull request as ready for review September 24, 2020 23:45
@emerick emerick requested a review from tmancey as a code owner September 24, 2020 23:45
@emerick emerick force-pushed the rewards-greaselion-twitter branch 2 times, most recently from 8645f8d to e28499a Compare September 25, 2020 23:12
@emerick emerick force-pushed the rewards-greaselion-twitter branch 2 times, most recently from f319632 to c9d366b Compare September 28, 2020 13:55
@emerick emerick requested a review from NejcZdovc September 28, 2020 13:56
@emerick emerick force-pushed the rewards-greaselion-twitter branch from c9d366b to 3ccbeb2 Compare September 28, 2020 15:58
const data = msg.data as MakeAPIRequest
handleMakeAPIRequest(data, (response: any) => {
port.postMessage({
type: 'MakeAPIRequest',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're using the same type string for both the request and the response. Do you think it would be more clear to use different names (e.g. OnAPIRequest, OnAPIResponse, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had Request and Response appended to all message types for a while when writing the YouTube script. I feel like it didn't really help with clarity and just made things wordier. Once the background script began making requests, it only added to the confusion (at least for me!) I'm going to try to stick with this nomenclature for consistency right now.

return response.json()
})
.then(responseData => sendResponse(responseData))
.catch(error => sendResponse(error))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're sending both errors and valid responses through the "response" field into the content script. Does the content script know how to tell the difference? Perhaps the message to the content script should include both "response" and "error" fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point, fixed.

@emerick emerick force-pushed the rewards-greaselion-twitter branch 3 times, most recently from 3402f4c to cffc880 Compare September 28, 2020 18:17
@emerick emerick requested a review from zenparsing September 28, 2020 23:34
@emerick emerick force-pushed the rewards-greaselion-twitter branch 2 times, most recently from 6affe6a to 35cd56c Compare September 29, 2020 21:07
@emerick emerick force-pushed the rewards-greaselion-twitter branch 3 times, most recently from 67f651f to cfa337d Compare October 2, 2020 03:23
Copy link
Contributor

@NejcZdovc NejcZdovc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. verified publisher doesn't have profile image https://twitter.com/lukemulks/status/1293113074317049856
    image

  2. should show publisher info https://twitter.com/brave/likes
    current:
    image
    expected:
    image

  3. inline tip is not showing correct publisher. It should show TNW Events, but it shows Geertje as it was cited by TNW
    https://twitter.com/tnwevents/status/1311659702598668288
    current:
    image
    expected:
    image

Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM++

@emerick emerick requested a review from NejcZdovc October 2, 2020 15:47
@emerick emerick force-pushed the rewards-greaselion-twitter branch 2 times, most recently from 4551fd4 to 5285464 Compare October 5, 2020 16:08
@emerick emerick added CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux labels Oct 5, 2020
@emerick emerick force-pushed the rewards-greaselion-twitter branch from 5285464 to 65aa51e Compare October 5, 2020 18:30
@emerick emerick removed CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux labels Oct 5, 2020
@emerick
Copy link
Contributor Author

emerick commented Oct 5, 2020

All CI platforms passed, waiting for final approval on brave/brave-site-specific-scripts#16 before merging.

@emerick emerick merged commit 49eef4f into master Oct 5, 2020
@emerick emerick deleted the rewards-greaselion-twitter branch October 5, 2020 22:00
@emerick emerick added this to the 1.17.x - Nightly milestone Oct 5, 2020
@johntringham
Copy link

johntringham commented Dec 16, 2020

I believe this change has caused an issue where the embedded tip button can't be turned off. There was a test to check whether disabling Rewards also disabled the Tip button, but this PR includes a change that disables it in this commit.

I might be wrong about this (first time looking at the codebase) but it looks like this PR rewrites the way the embedded tip buttons are created/rendered, but doesn't include any reference to the "props.rewardsData.inlineTip" preference, and so will be on by default no matter what the preference is set to.

@emerick
Copy link
Contributor Author

emerick commented Dec 16, 2020

@johntringham After you disable the tip button, it requires you to restart the browser (we're working on removing that limitation). If you do that, is the button disabled for you?

@johntringham
Copy link

johntringham commented Dec 17, 2020

Yep, I've tried that (and several other things) - the Tip icon still appears. It looks like this bug is there for Twitter, Github and Reddit.

This has been raised in several places over the last couple of months:
https://community.brave.com/t/no-way-of-removing-tip-button-from-twitter/188046/4
https://community.brave.com/t/twitter-showing-bat-tip-button-when-turned-off-causing-glitching/168542
brave/brave-browser#13223
brave/brave-browser#13222
brave/brave-browser#13157
brave/brave-browser#12870

Edit: Apologies - restarting the browser did fix it! I thought I had tried that but it looks like I had a couple of windows open in a different desktop, so the brave processes didn't fully end. Sorry about that - I'll stop posting on old PR's now :)

@emerick
Copy link
Contributor Author

emerick commented Dec 17, 2020

@johntringham No worries at all, glad it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment