Element Hider for The Indian Express and The Hindu

Hides ad placeholders and empty ads on The Indian Express and The Hindu

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Element Hider for The Indian Express and The Hindu
// @namespace    http://greasyfork.org/
// @version      0.8
// @description  Hides ad placeholders and empty ads on The Indian Express and The Hindu
// @author       Todo Pertin
// @match        https://indianexpress.com/*
// @match        https://www.thehindu.com/*
// @license      GNU GPLv3
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Add the class names and ID of elements you want to hide in the arrays below
    const elementsToHide = [
        'osv-ad-class',
        'ie-int-campign-ad',
        'adboxtop',
        'add-first',
        'OMIDYAR_HOME_EVENTS'
    ];

    const idsToHide = [
        'articledivrec'
    ];

    function hideElements() {
        // Hide elements by class name
        elementsToHide.forEach(className => {
            const elements = document.getElementsByClassName(className);
            for (const element of elements) {
                element.style.display = 'none';
            }
        });

        // Hide elements by ID
        idsToHide.forEach(id => {
            const element = document.getElementById(id);
            if (element) {
                element.style.display = 'none';
            }
        });
    }

    // Run the function when the DOM is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', hideElements);
    } else {
        hideElements();
    }
})();