goodfon

remove ads

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        goodfon
// @namespace   [email protected]
// @description remove ads
// @include     https://www.goodfon.ru/
// @version     1
// @grant       none
// ==/UserScript==

let bigBanner = document.querySelector(`div[style*='baner_f']`);
if(bigBanner) {
    bigBanner.parentElement.parentElement.removeChild(bigBanner.parentElement);
}

let bannerObserver = new MutationObserver(mutations => {
    mutations.forEach(mutation => {
        if(mutation.addedNodes.length > 0) {
            if(mutation.target.id.includes('google_ad')) {
                let banner = mutation.target.parentElement;
                banner.parentElement.removeChild(banner);
            } else if(mutation.target.id.includes('rb_ad')) {
                let banner = mutation.target.parentElement.parentElement.parentElement;
                banner.parentElement.removeChild(banner);
            }
        }
    });
});
bannerObserver.observe(document.body, { childList: true, subtree: true });  

let paragraphs = Array.from(document.querySelectorAll('div.container > p'));
if(paragraphs.length > 0) {
    paragraphs.forEach(p => p.parentElement.removeChild(p));
}

let footer = document.getElementById('footer');
if(footer) {
    footer.parentElement.removeChild(footer);
}

let widgetLine = document.querySelector('.menu_l > noindex');
if(widgetLine) {
    widgetLine.parentElement.removeChild(widgetLine);
}