-
-
Save DF-wu/45df97ed76fb814cadf9d42e9826bae5 to your computer and use it in GitHub Desktop.
Remove Facebook Ad Posts(zh-TW)
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 Remove Facebook Ad Posts | |
// @version 1 | |
// @author STW | |
// @match https://www.facebook.com/ | |
// ==/UserScript== | |
unsafeWindow.deletedPost = []; | |
unsafeWindow.deletedPostOwner = []; | |
setInterval(() => { | |
Array.from(document.querySelectorAll('div')).filter(d => d.getAttribute('role') === 'article').forEach(div => { | |
if (Array.from(div.querySelectorAll('a')).filter(a => a.getAttribute('role') === 'button').filter(a => a.innerText === '贊助').length === 1) { | |
unsafeWindow.deletedPost.push(div.innerHTML); | |
unsafeWindow.deletedPostOwner.push({name: div.querySelector('h5 a').innerText, url: div.querySelector('h5 a').href}); | |
div.innerHTML = ''; | |
} | |
}); | |
}, 1000); | |
unsafeWindow.showDeletedPosts = function() { | |
for (let i = 0; i < unsafeWindow.deletedPostOwner.length; ++i) console.log(`${i}: ${unsafeWindow.deletedPostOwner[i].name}\n${unsafeWindow.deletedPostOwner[i].url}`); | |
} | |
unsafeWindow.showFullPostByIndex = function(index) { | |
console.log(unsafeWindow.deletedPost[index]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment