Last active
July 27, 2017 12:28
-
-
Save Cosmeen/f40ad728e355adc597bb2c3413ba7d16 to your computer and use it in GitHub Desktop.
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 facebook sponsored stories | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1alpha | |
// @description try to take over the world! | |
// @author Cosmeen | |
// @match https://www.facebook.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
function onChangeHandler(event) { | |
var stories = document.querySelectorAll('._1dwg'); | |
stories.forEach(function(el,i){ | |
var re = new RegExp("(Sponsored)"); | |
if (re.test(el.textContent)) { | |
el.parentNode.parentNode.parentNode.style.display = 'none'; | |
} | |
}); | |
stories = null; | |
} | |
document.querySelectorAll('div[role="feed"]')[0].addEventListener('DOMSubtreeModified', onChangeHandler); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment