Greasy Fork

Free Spanish Press

Remove adBlockers detector for spanish press

目前为 2021-07-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         Free Spanish Press
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Remove adBlockers detector for spanish press
// @author       ALeX Molero
// @match        *://*.elmundo.es/*
// @match        *://*.abc.es/*
// @match        *://*.20minutos.es/*
// @match        *://*.elpais.com/*
// @match        *://*.marca.com/*
// @match        *://*.as.com/*
// @match        *://*.larazon.es/*
// @match        *://*.libertaddigital.com/*
// @match        *://*.elespanol.com/*
// @match        *://*.elconfidencial.com/*
// @match        *://*.okdiario.com/*
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// @license CC-BY-NC-SA-4.0; https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
// ==/UserScript==

/* jshint esversion: 6 */

(function() {
    'use strict';
    const $ = jQuery;
    const divElement = '.fc-ab-root';
    const timeOut = 500
    const hostName = window.location.hostname;
    const retries = 30;
    const domainName = hostName.substring(hostName.lastIndexOf(".", hostName.lastIndexOf(".") - 1) + 1);

    const acceptCookies = () => {
        const CookiesButton = '#didomi-notice-agree-button';
        adblockerDetection(CookiesButton, () => {
            $(CookiesButton).trigger('click');
        }, 0);
    }

    const adblockerDetection = (selector, callback, retry) => {
        retry++;

        if (jQuery(selector).length) {
            callback();
        } else {
            if(retry <= retries) {
                setTimeout(() => {
                    adblockerDetection(selector, callback, retry);
                }, timeOut);
            }
        }
    };

    $( document ).ready(() => {
        adblockerDetection(divElement, () => {
            $(divElement).remove();
            $('body').css("overflow", "auto");
        }, 0);

        acceptCookies();
    });

    const removeAddsElMundo = () => {
        $('#banda_suscripcion').remove();
    }

    const removeAddsElPais = () => {
        adblockerDetection('#sfcampaign', () => {
            $('#sfcampaign').remove();
        }, 0);
    }

    const removeAddsAbc = () => {
        $('.cintillo-dinamico.premium').remove();
        const removeItem = '#engagement-top';
        adblockerDetection(removeItem, () => {
            $(removeItem).remove();
            $('body').css("overflow", "auto");
        }, 0);
    }

    const removeAddsElEspanol = () => {
        const removeItem = '.tp-container-inner';
        adblockerDetection(removeItem, () => {
            $(removeItem).remove();
        }, 0);
    }

    switch(domainName) {
        case 'abc.es': removeAddsAbc(); break;
        case 'elmundo.es': removeAddsElMundo(); break;
        case 'marca.com': removeAddsElMundo(); break;
        case 'elpais.com': removeAddsElPais(); break;
        case 'elespanol.com': removeAddsElEspanol(); break;
        default: return;
    }
})();