ScarShow

< IS >

隱藏 Facebook 廣告 (Google Chrome)

最近覺得Facebook側邊的廣告實在是很惱人,因為我用Chrome居多所以寫了一隻小小的Google Chrome Extension來解決這個問題。

點底下的連結安裝後,他就會自動把廣告欄位隱藏起來。放心本人為人正直不會亂放病毒。

下面就附上Source Code,然後Extension本身是用Javascript寫得,Oguma水美媒就這麼簡單。

按這邊安裝

// ==UserScript==
// @name           Facebook Ads Blocker
// @version        0.2.2
// @author         Scar Wu
// @namespace      https://scar.tw
// @description    Hidden Facebook Ads
// @include        *
// ==/UserScript==

window.onload = function() {
    hideAds();
};

document.addEventListener('DOMNodeInserted', function() {
    hideAds();
});

function hideAds() {
    if(document.location.host == 'www.facebook.com') {
        var pagelet_side_ads = document.getElementById('pagelet_side_ads');
        if(pagelet_side_ads != undefined)
            pagelet_side_ads.innerHTML = null;

        var ego_column = document.getElementsByClassName('ego_column');
        if(ego_column != undefined && ego_column.length > 0) {
            for(var index in ego_column) {
                if(ego_column[index].getElementsByClassName('adsCategoryTitleLink') != undefined) {
                    ego_column[index].innerHTML = null;
                    break;
                }
            }
        }

        var fbTimelineSideAds = document.getElementsByClassName('fbTimelineSideAds');
        for(var index in fbTimelineSideAds) {
            fbTimelineSideAds[index].innerHTML = null;
        }
    }
}