Last active
July 24, 2019 13:21
-
-
Save rohenaz/d8dfd46638c09446878edbdef80f2919 to your computer and use it in GitHub Desktop.
UserScript - Twitter no promoted tweets
This file contains 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 Twitter No Promoted | |
// @namespace https://github.com/rohenaz | |
// @version 0.1 | |
// @description remove promoted tweets | |
// @author Satchmo | |
// @match https://*.twitter.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setInterval(removePromotedImages, 1000); | |
function removePromotedImages() { | |
let col = document.querySelector('[data-testid="primaryColumn"]') | |
let spanTags = col.getElementsByTagName("span") | |
let searchText = "Promoted" | |
let foundTags = [] | |
for (let i = 0; i < spanTags.length; i++) { | |
if (spanTags[i].textContent == searchText) { | |
if (spanTags[i].style.display !== "none") { | |
foundTags.push(spanTags[i]) | |
} | |
} | |
} | |
console.log('found these', foundTags) | |
let len = foundTags.length; | |
while(len--) { | |
let el = foundTags[len].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement | |
console.log('removing', el) | |
el.style.display = "none"; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment