Skip to content

Instantly share code, notes, and snippets.

@vanadium23
Created December 3, 2019 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanadium23/969c7642fba203c7824cc8a2473ee125 to your computer and use it in GitHub Desktop.
Save vanadium23/969c7642fba203c7824cc8a2473ee125 to your computer and use it in GitHub Desktop.
Tampermonkey script for twitter social activity
// ==UserScript==
// @name Remove twitter social actions
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove likes and retweets from twitter
// @author @vanadium23
// @match https://twitter.com/*
// @ran-at document-idle
// @grant none
// ==/UserScript==
function mainLoop() {
for (let type of ['retweet', 'like']) {
for (let button of document.querySelectorAll(`div[data-testid="${type}"]`)) {
button.parentNode.removeChild(button);
}
}
}
(function() {
'use strict';
if (typeof MutationObserver === 'function') {
let observerConfig = {
attributes: true,
characterData: true,
childList: true,
subtree: true,
};
let body = document.getElementsByTagName('body')[0];
let observer = new MutationObserver(mainLoop);
observer.observe(body, observerConfig);
} else {
mainLoop();
setInterval(mainLoop, 200);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment