Add 'TwitterFilterBubble.js'

This commit is contained in:
jpk 2021-12-20 11:50:25 +01:00
parent 86bca93f56
commit 2d445faa2c
1 changed files with 45 additions and 0 deletions

45
TwitterFilterBubble.js Normal file
View File

@ -0,0 +1,45 @@
// ==UserScript==
// @name Twitter Filter Bubble
// @namespace https://twitter.com
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://twitter.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.githubusercontent.com/scarpent/ba8e369f1187fa990b98d1f58b2c013d/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js
// @grant none
// ==/UserScript==
function hideTwitterPromotion() {
'use strict';
var articles = document.getElementsByTagName("article");
for (var i = 0; i < articles.length; i++) {
var article = articles[i];
var spans = article.getElementsByTagName("span");
for (var j = 0; j < spans.length; j++) {
if (spans[j].innerText == "Promoted") {
article.parentNode.remove();
console.debug('Deleted a promoted tweet ', article);
}
}
}
};
function detoxTwitter() {
'use strict';
var div = document.querySelector('[aria-label="Timeline: Trending now"]');
if (div !== null) {
div.remove();
}
};
function cleanTwitter() {
'use strict';
hideTwitterPromotion();
detoxTwitter();
};
waitForKeyElements("article", cleanTwitter);