Thingiverse AdBlock

Blocks ads from Thingiverse

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name           Thingiverse AdBlock
// @description    Blocks ads from Thingiverse 
// @description:de Blendet Werbung auf Thingiverse aus
// @author         Tobse
// @license        MIT
// @name:de        Thingiverse AdBlock
// @name:en        Thingiverse AdBlock
// @match          https://www.thingiverse.com/thing*
// @run-at         document-idle
// @version        0.1.2.20221001100000
// @namespace      https://github.com/TobseF
// ==/UserScript==

function blockAds(){
    let found = '';
    let i = 0;
    let query = "//div[contains(@class,\"AdCard\")]"
    do {
        found  = document.evaluate(query, document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue
        if(found  != null){
            found.remove()
        }
    } while (found  != null && i < 10);
}

(new MutationObserver(waitForGallery)).observe(document, {childList: true, subtree: true});

function waitForGallery(changes, observer) {
    // Wait until image gallery is visible
    if (document.querySelector('[class^="AdCard"]')) {
        observer.disconnect();
        blockAds();
    }
}