Created
December 23, 2022 02:46
-
-
Save Sneppys/050bf4d156109446838c854152a6f9fb to your computer and use it in GitHub Desktop.
Hide Twitter Views userscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Hide Tweet Views | |
// @version 0.1 | |
// @description Hide view count in twitter timeline | |
// @author Snep | |
// @match https://twitter.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com | |
// @grant none | |
// ==/UserScript== | |
function hideButtons() { | |
const tweetButtons = document.querySelectorAll('[data-testid="tweet"] [role="group"]>*:not([style])'); | |
for (const button of tweetButtons) { | |
for (const child of button.children) { | |
const attrib = child && child.getAttribute && child.getAttribute("aria-label"); | |
if (attrib && attrib.includes("analytics")) { | |
button.style = "display: none"; | |
} | |
} | |
} | |
setTimeout(hideButtons, 100); | |
} | |
(function() { | |
'use strict'; | |
hideButtons(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI to make the script a bit more efficient, you can run the code inside a mutation observer after the initial run in order to prevent the need to keep running the code on a timeout. something like this: