// ==UserScript== // @name PayCheck for X (Formerly Twitter) // @description See (a very VERY rough idea of) how much money a post is worth. // @version 0.0.2 // @author yungsamd17 & t3dotgg // @namespace https://github.com/yungsamd17/twitter-userscript // @namespace https://github.com/t3dotgg/paycheck-extension // @icon https://raw.githubusercontent.com/yungsamd17/paycheck-userscript/main/assets/PCX-icon-48.png // @match https://twitter.com/* // @match https://mobile.twitter.com/* // @match https://tweetdeck.twitter.com/* // @match https://x.com/* // @grant none // @run-at document-end // @downloadURL none // ==/UserScript== function convertToRawCount(number) { const cleaned = number.replace(/,/g, ""); const base = parseFloat(cleaned); if (number.toLowerCase().match(/k/)) { return Math.round(base * 1000); } else if (number.toLowerCase().match(/m/)) { return Math.round(base * 1000000); } else if (number.toLowerCase().match(/b/)) { return Math.round(base * 1000000000); } else { return base; } } function convertToDollars(number) { const rawCount = convertToRawCount(number); const processed = rawCount * 0.000026; if (processed < 0.1) return processed.toFixed(5); return processed.toFixed(2); } const globalSelectors = {}; globalSelectors.postCounts = `[role="group"][id*="id__"]:only-child`; globalSelectors.articleDate = `[role="article"][aria-labelledby*="id__"][tabindex="-1"] time`; globalSelectors.analyticsLink = " :not(.dollarBox)>a[href*='/analytics']"; globalSelectors.viewCount = globalSelectors.postCounts + globalSelectors.analyticsLink; const innerSelectors = {}; innerSelectors.dollarSpot = "div div:first-child"; innerSelectors.viewSVG = "div div:first-child svg"; innerSelectors.viewAmount = "div div:last-child span span span"; innerSelectors.articleViewAmount = "span div:first-child span span span"; function doWork() { const viewCounts = Array.from( document.querySelectorAll(globalSelectors.viewCount) ); const articleViewDateSection = document.querySelector(globalSelectors.articleDate); if(articleViewDateSection) { let rootDateViewsSection = articleViewDateSection.parentElement.parentElement.parentElement; if(rootDateViewsSection?.children.length === 1) { // we're dealing with the