Igor Tolkov

October 2023

12347910111214151617192225262728293031

Blocking ads on Facebook, Part 1

Here’s a Facebook ad-block script, version 0.1. This is for the new Facebook with the gray bar on the left. Adblock can’t handle the ads (yet) since Facebook disguises them as regular posts.

window.setInterval(function(){
    var s = document.getElementsByClassName("uiStreamAdditionalLogging");
    for(var i in s){
        var a = s[i]; if(!a.className) continue;
        while(a.className.indexOf("_6ns")==-1) a = a.parentNode;
        a.style.display="none";
    }
}, 100);

Or, in a one-line bookmarklet:

javascript:void(window.setInterval(function(){var s=document.getElementsByClassName("uiStreamAdditionalLogging");for(var i in s){var a=s[i];if(!a.className)continue;while(a.className.indexOf("_6ns")==-1 )a = a.parentNode;a.style.display="none";}},100));