您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove Sponsored blocks from Facebook
当前为
// ==UserScript== // @name Facebook remove sponsored ads blocks // @version 1.9.8 // @description Remove Sponsored blocks from Facebook // @author Sly_North // @match https://www.facebook.com/* // @exclude https://www.facebook.com/privacy/* // @exclude https://www.facebook.com/settings/* // @exclude https://www.facebook.com/marketplace/* // @namespace https://gf.qytechs.cn/en/users/759669-sly-north // @license MIT // @grant none // ==/UserScript== console.log('Start RemoveAllSponsored'); function getVisibleContent(e, spanBottom) { var t = e.innerText.replaceAll("\n",""); var children = e.childNodes; while (children.length == 1) children = children[0].childNodes; var spanBottom = e.getBoundingClientRect().bottom; children = Array.from(children).filter((c) => c.getBoundingClientRect().top <= spanBottom); var a = []; for (var c of children) { var order = getComputedStyle(c).order; if (order && window.getComputedStyle(c).display !== 'none') { a[order] = c.innerText; // console.log(c.style.order,'=',c.innerText, ' y=',c.getBoundingClientRect().top,' vs span.bottom=', spanBottom); } } if (a.length == 0) a = t.split(); var intext = a.join().replaceAll(",","").replaceAll("\n",""); // if (a.length > 0) console.log('Array = ', intext, ' -OR- ', a.join().replaceAll(",","").replaceAll("\n","")); if (intext == "") intext = t; return intext; } function RemoveAllSponsored() { setTimeout(RemoveAllSponsored, 1000); // console.log('RemoveAllSponsored'); var elts = Array.from(document.getElementsByTagName('span')); elts = elts.filter((e) => {var br = e.getBoundingClientRect(); return br.bottom >= 0 && br.top <= screen.height + 300}); // TODO support more languages if there's interest. const keywords = [/S.*p.*o.*n[^ ]*s.*o[^ ]*r[^ ]*e[^ ]*d/, /C[^ ]*o.*m[^ ]*m.*a[^ ]*n.*d[^ ]*v.*i.*t/, /S[^ ]*p[^ ]*o.*n.*s[^ ]*o[^ ]*r[^ ]*i/, /R.*e[^ ]*k[^ ]*l.*a[^ ]*m.*o/, /P.*u[^ ]*b.*l[^ ]*i.*c.*i.*d/, /G.*e.*s[^ ]*p.*o[^ ]*n.*s.*e.*r/, /P.*a.*t[^ ]*r.*o.*c[^ ]*i.*n[^ ]*a.*d.*o/, /s[^ ]*u.*g[^ ]*e.*r[^ ]*i.*s[^ ]*d.*o.*s/, /贊.*助/, /R.*e.*m.*e.*m.*b.*e.*r.*P.*a.*s.*s.*w.*o.*r.*d/]; const spansEndPage = 600; var nbrRemoved = 0; var nbrSuggestedRemoved = 0; var nbrSpans = elts.length; for (var i = elts.length - 1; i >= 0; --i) { var e = elts[i]; if (e.style.display) continue; // Already removed var boundingRect = e.getBoundingClientRect(); if (boundingRect.width == 0 || boundingRect.height == 0) continue; // Not visible var t = e.innerText; if (e.parentElement.tagName != 'SPAN') { if (t == 'Suggested for you' || t == 'Remember Password' || t == 'Reels and short videos') { let parent = e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement; console.log('Removing suggested span ', i, '[', parent.innerText.replaceAll("\n", " "), '] matching ', regexp); parent.style.display = "none"; e.style.display = "none"; ++nbrSuggestedRemoved; } continue; } var intext = getVisibleContent(e); if (intext.length > 0) for (k in keywords) { var regexp = keywords[k]; if (intext.match(keywords[k])) { let parent = e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement; console.log('Removing ads span', i, 'w=', boundingRect.width, 'h=', boundingRect.height, '[', parent.innerText.replaceAll("\n", " "), '] matching ', regexp, ' at ', intext); parent.style.display = "none"; e.style.display = "none"; ++nbrRemoved; break; } } } // console.log('nbr removed spans=',nbrRemoved); } setTimeout(RemoveAllSponsored, 1000); console.log('Done');
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址