Skip to content

Instantly share code, notes, and snippets.

@Cosmeen
Last active July 27, 2017 12:28
Show Gist options
  • Save Cosmeen/f40ad728e355adc597bb2c3413ba7d16 to your computer and use it in GitHub Desktop.
Save Cosmeen/f40ad728e355adc597bb2c3413ba7d16 to your computer and use it in GitHub Desktop.
// ==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