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

Support Tips for new Twitter site #4548

Closed
mandar-brave opened this issue May 23, 2019 · 9 comments · Fixed by brave/brave-core#2943
Closed

Support Tips for new Twitter site #4548

mandar-brave opened this issue May 23, 2019 · 9 comments · Fixed by brave/brave-core#2943

Comments

@mandar-brave
Copy link

Issue:
It seems Twitter is A/B testing multiple sets of pages for users who are willing to opt in to those. One of those pages is mobile.twitter.com which is the responsive version. Our current solution for Twitter tipping breaks on the new site.

Solve:
Preferably fix prior to release.
Old site works reliably so far.

cc @emerick @NejcZdovc @alexwykoff

@mandar-brave mandar-brave added feature/rewards priority/P2 A bad problem. We might uplift this to the next planned release. labels May 23, 2019
@jonathansampson
Copy link
Contributor

jonathansampson commented May 23, 2019

Regarding selectors: [data-testid="tweet"] matches only Tweet elements on the mobile/new Twitter. [role="group"] matches only the action elements beneath Tweets.

@emerick
Copy link
Contributor

emerick commented May 23, 2019

That's really helpful! The other half of the puzzle would be gathering the various metadata associated with the tweet. We currently gather the following pieces of metadata:

  • User ID of tweet author
  • Real name of tweet author
  • Twitter handle of tweet author
  • Unique tweet ID
  • Tweet timestamp
  • Tweet text

Haven't looked in depth, but hoping it's not too hard to gather those once we have the tweet itself.

@jonathansampson
Copy link
Contributor

New DOM doesn't make things easy. The following gathers most of the data, but the numerical user ID does not appear to be retrievable from the DOM.

const getMetaData = tweet => {

    const names = tweet.getElementsByTagName("a")[1].textContent.split("@")
    const status = tweet.querySelector("a[href*='/status/']")

    return {
        name: names[0],
        screenName: `@${names[1]}`,
        userId: "",
        tweetId: status.href.match(/\d+/)[0],
        tweetTimestamp: status.querySelector('time').dateTime,
        tweetText: tweet.querySelector('[lang]').textContent
    }
}

@mandar-brave mandar-brave added priority/P1 A very extremely bad problem. We might push a hotfix for it. and removed priority/P2 A bad problem. We might uplift this to the next planned release. labels Jul 16, 2019
@mandar-brave
Copy link
Author

@emerick move this to P1; we need to hotfix this in to current release.
@NejcZdovc FYI

@emerick
Copy link
Contributor

emerick commented Jul 17, 2019

@mandar-brave It looks like promoted tweets don't contain a timestamp link, which also happens to be where we scrape the tweet ID from. We need the tweet ID in order to quote the tweet when tweeting about our tip (it may be used elsewhere too, but that was the main place I saw it being used).

I would suggest for now that we disallow tipping promoted tweets on new Twitter, as I'm not sure we currently have a viable workaround for this. Let me know what you think, however.

@mandar-brave
Copy link
Author

@emerick i am good with getting what we can; we should get a PR out without tipping promoted tweets ATM; leave the issue open to see if we can find a fix for the remain topics.

@davidtemkin for his opinion!

@GeetaSarvadnya
Copy link

GeetaSarvadnya commented Jul 25, 2019

@emerick For Promoted twitter tweets, the inline Tip link is NOT shown. Is this expected?. Thanks!

image

@emerick
Copy link
Contributor

emerick commented Jul 25, 2019

@GeetaSarvadnya Yes, for technical reasons (basically, we're unable to retrieve the tweet ID for promoted tweets) we don't allow tipping promoted tweets and thus don't show the tip icon for them.

@GeetaSarvadnya
Copy link

GeetaSarvadnya commented Jul 25, 2019

Verification passed on

Brave 0.67.117 Chromium: 76.0.3809.62 (Official Build) (64-bit)
Revision 7b77856b3aa34d72f246d12340fc1ded8b2c0e83-refs/branch-heads/3809@{#798}
OS Windows 10 OS Version 1803 (Build 17134.523)

image

  • Verified inline Tip icon display when Rewards is enabled
    image

  • Verified Tip icon disappear from twitter feed when uncheck "Twitter" checkbox in Tips Settings

image

  • Verified Tip icon appear again in twitter feed when checking "Twitter" checkbox in Tips Settings

image

Verified passed with

Brave 0.67.117 Chromium: 76.0.3809.62 (Official Build) (64-bit)
Revision 7b77856b3aa34d72f246d12340fc1ded8b2c0e83-refs/branch-heads/3809@{#798}
OS Mac OS X

Verification passed on

Brave 0.67.117 Chromium: 76.0.3809.62 (Official Build) (64-bit)
Revision 7b77856b3aa34d72f246d12340fc1ded8b2c0e83-refs/branch-heads/3809@{#798}
OS Ubuntu 18.04 LTS

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

Successfully merging a pull request may close this issue.

7 participants