Makes sponsored feeds invisible on facebook.com
当前为
// ==UserScript==
// @name Facebook no ads
// @namespace http://tampermonkey.net/
// @version 0.5
// @description Makes sponsored feeds invisible on facebook.com
// @author Darmikon
// @match https://www.facebook.com/*
// @grant none
// ==/UserScript==
const throttle = (func, limit) => {
let inThrottle
return function() {
const args = arguments
const context = this
if (!inThrottle) {
func.apply(context, args)
inThrottle = true
setTimeout(() => inThrottle = false, limit)
}
}
}
const trimAds = () => {
const feeds = document.getElementById('contentArea').querySelectorAll('[id*=hyperfeed_story_id]');
feeds.forEach(feed => {
try {
const title = feed
.querySelector('[data-testid*="story"]');
// feed_subtitle_263;376364045765261;0;2201380379930276;1552581075:5551613536253095581:5:0:11326
const id = title.id || '';
const hackSpace = id.split(';')[2];
const detectAdsCondition = !title.id || hackSpace == 0;
if(detectAdsCondition) {
// console.log('killed', title);
feed.style.display = "none";
}
} catch (e) {}
});
}
(function() {
const throttleKill = throttle(trimAds, 1000);
throttleKill();
window.addEventListener('scroll', throttleKill);
window.addEventListener('resize', throttleKill);
})();