Created
July 10, 2017 12:22
-
-
Save AoDev/178c68aa464865bf38e1b750afe86c35 to your computer and use it in GitHub Desktop.
Remove facebook ads from timeline
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
// Remove the ads in your Facebook timeline. | |
// Depending on the language you use in FB, you will need to update the keyWord. | |
// The keyWord is the title used in facebook ads. Everytime this title is found, | |
// the corresponding content will be removed from the timeline. | |
// You can also adjust the check interval, it depends on how fast you scroll | |
// the content usually. | |
// How to use: | |
// - You can use a browser extension that injects that script into the page. | |
// Eg: https://chrome.google.com/webstore/detail/css-and-javascript-inject/ckddknfdmcemedlmmebildepcmneakaa | |
// Copy paste this whole script so it is applied on FB page. | |
const keyWord = 'publicidad' | |
function findElements(selector) { | |
return [].slice.call(document.querySelectorAll(selector)) | |
} | |
function findParent(node, cssClass) { | |
if (node.nodeName === '#document') { | |
return null | |
} | |
if (node.className.includes(cssClass)) { | |
return node | |
} | |
return findParent(node.parentNode, cssClass) | |
} | |
function findAdLinks() { | |
var links = findElements('a') | |
return links.filter((link) => link.innerText.toLowerCase() === keyWord) | |
} | |
setInterval(() => { | |
var adLinks = findAdLinks() | |
adLinks.forEach((link) => { | |
const parent = findParent(link, 'fbUserContent') | |
if (parent) { | |
parent.remove() | |
} | |
}) | |
}, 5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment