Skip to content

Commit

Permalink
Removed CSS for hiding focused tweet metrics which have been removed …
Browse files Browse the repository at this point in the history
…by Twitter

Hide bookmark metrics which now display in the action bar under focused tweets
  • Loading branch information
insin committed Sep 12, 2023
1 parent c80cd74 commit 06494f9
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3117,33 +3117,11 @@ function configureHideMetricsCss(cssRules, hideCssSelectors) {
`)
}

let individualTweetMetricSelectors = [
config.hideRetweetMetrics && '[href$="/retweets"]',
config.hideLikeMetrics && '[href$="/likes"]',
config.hideQuoteTweetMetrics && '[href$="/retweets/with_comments"]',
].filter(Boolean).join(', ')

if (individualTweetMetricSelectors) {
// Individual tweet metrics
hideCssSelectors.push(
`body.Tweet a:is(${individualTweetMetricSelectors}) > :first-child`,
`[aria-modal="true"] [data-testid="tweet"] a:is(${individualTweetMetricSelectors}) > :first-child`
)
// Fix display of whitespace after hidden metrics
cssRules.push(
`body.Tweet a:is(${individualTweetMetricSelectors}), [aria-modal="true"] [data-testid="tweet"] a:is(${individualTweetMetricSelectors}) { white-space: pre-line; }`
)
}

if (config.hideBookmarkMetrics) {
// Bookmark metrics are the only one without a link
hideCssSelectors.push('[data-testid="tweet"][tabindex="-1"] [role="group"]:not([id]) > div > div')
}

let timelineMetricSelectors = [
config.hideReplyMetrics && '[data-testid="reply"]',
config.hideRetweetMetrics && '[data-testid$="retweet"]',
config.hideLikeMetrics && '[data-testid$="like"]',
config.hideBookmarkMetrics && '[data-testid$="bookmark"]',
].filter(Boolean).join(', ')

if (timelineMetricSelectors) {
Expand Down Expand Up @@ -4536,15 +4514,6 @@ function tweakCommunityMembersPage() {
async function tweakFocusedTweet($focusedTweet, options) {
let {observers} = options
if ($focusedTweet) {
// TODO Observe this if it's singular to catch it moving to plural
let $retweetsText = $focusedTweet.querySelector('a:is([href$="/retweets"], [href$="/reposts"]) > span > span')
if ($retweetsText) {
let currentText = $retweetsText.textContent
if (currentText != getString('RETWEETS') && currentText != getString('RETWEET')) {
$retweetsText.textContent = getString(currentText == getString('REPOSTS') ? 'RETWEETS' : 'RETWEET')
}
}

if (mobile) {
let $textArea = /** @type {HTMLTextAreaElement} */ (await getElement('textarea', {
context: $focusedTweet.parentElement,
Expand Down

0 comments on commit 06494f9

Please sign in to comment.