Facebook:隐藏赞助和推荐内容
脚本监视 Facebook 信息流并隐藏赞助和"为你推荐"的帖子。
可复制的代码
(function () {
var TERMS = ['Sponsored', 'Suggested for you', 'Sponsorowane', 'Propozycja dla Ciebie'];
function clean(root) {
var posts = (root || document).querySelectorAll('div[role="feed"] > div');
posts.forEach(function (post) {
var text = post.innerText || '';
for (var i = 0; i < TERMS.length; i++) {
if (text.indexOf(TERMS[i]) !== -1 && text.length < 4000) {
post.style.display = 'none';
return;
}
}
});
}
clean(document);
var obs = new MutationObserver(function (muts) {
muts.forEach(function (m) { clean(m.target); });
});
obs.observe(document.body, { childList: true, subtree: true });
})();
如何使用此示例
- 用上方按钮复制代码。
- 安装 JustZix(2 分钟),在目标页面打开扩展。
- 添加一条匹配该页面的新规则。
- 将代码粘贴到规则的 JavaScript 面板并保存 — 每次访问页面时都会运行。
为此示例评分
暂无评分 — 成为第一个。