Last active
September 10, 2016 07:48
-
-
Save kirbdee/3c891a1e2aa5e66a7a8e92c2229af926 to your computer and use it in GitHub Desktop.
Blocking FB's "Unblockable Ads." Independently from ABP
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
(function() { | |
//test | |
function removeAds(sponsoredItems) { | |
for (var i in sponsoredItems) { | |
if(sponsoredItems.hasOwnProperty(i)){ | |
findAdWrapper(sponsoredItems[i]); | |
} | |
} | |
} | |
//Look for main wrapper | |
function findAdWrapper(item) { | |
//console.log(item) | |
if(item.tagName === "BODY"){ | |
return; | |
} | |
if(item.className.indexOf('_5jmm _5pat _3lb4 _59m') >= 0) { | |
console.warn("'REMOVED UNBLOCKABLE AD'") | |
item.remove(); | |
return; | |
} | |
findAdWrapper(item.parentNode); | |
} | |
var startScroll=0 | |
//Helps set delay on when to run ad removal function, for performance | |
var timeout = null; | |
function scrollPace() { | |
window.clearTimeout(timeout); | |
timeout = setTimeout(function(){ | |
if(startScroll<document.body.scrollHeight) { | |
//find all the "sponsored" tags | |
removeAds(document.getElementsByClassName('uiStreamSponsoredLink')); | |
startScroll=document.body.scrollHeight; | |
} | |
},10) | |
} | |
//add scroller | |
document.addEventListener('scroll',function(){ | |
scrollPace() | |
}) | |
//start removals | |
removeAds(document.getElementsByClassName('uiStreamSponsoredLink')); | |
try{ | |
//lazy catch incase someone already is using ABP | |
//this removes the side Ads | |
document.getElementsByClassName('ego_column')[0].remove() | |
} catch(e) { | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ABP FIlter
facebook.com##DIV[id^="substream_"] ._5jmm[data-dedupekey][data-cursor][data-xt-vimpr="1"][data-ftr="1"][data-fte="1"]