Skip to content

Instantly share code, notes, and snippets.

@Bowiemtl
Last active January 5, 2023 20:44
Show Gist options
  • Select an option

  • Save Bowiemtl/79bb0bb36a8d5bb7ed53358cca2d4d79 to your computer and use it in GitHub Desktop.

Select an option

Save Bowiemtl/79bb0bb36a8d5bb7ed53358cca2d4d79 to your computer and use it in GitHub Desktop.
Tampermonkey script to remove the views you see under every tweet. (Not tested across browsers or versions)
// ==UserScript==
// @name Remove twitter analytics
// @namespace http://tampermonkey.net/
// @version 1.0
// @description removes the ugly view analytics from twitter
// @author Bowiemtl
// @match *://*.twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
/*
* Just a simple script to remove the views from showing up under every tweet.
* This is not robust in any way, it is not tested extensively nor do I plan to but feel free to modify it in any way if needed.
* As of v1.0 the focussed tweet has the views nested where as non-focussed tweets do not. This makes an empty div linger around and take up space
* Update 2023-03-01: Unintended side effect; you can't delete your own tweet with this script installed by clicking the 3 dots for the dropdown.
*/
function removeAnalytics () {
let elements = document.querySelectorAll('a[href*="analytics"]');
elements.forEach(element => {
element.parentNode.remove();
});
}
const observer = new MutationObserver(removeAnalytics);
observer.observe(document, { childList: true, subtree: true });
@giseledute
Copy link

thank you!!

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