RIP HLTV BET

Remove hltv.org Annoy AD

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name                RIP HLTV BET
// @name:zh-CN          HLTV 广告去除插件
// @namespace           https://github.com/wolfcon/RIP-HLTV-BET
// @version             2.5
// @description         Remove hltv.org Annoy AD
// @description:zh-CN   清除那些🤮背景赌博广告.
// @author              Frank
// @require             https://code.jquery.com/jquery-3.6.0.min.js
// @match               https://*.hltv.org/*
// @icon                https://www.hltv.org/img/static/favicon/favicon-32x32.png
// @license             MIT
// @run-at              document-body
// ==/UserScript==

const filters = [
    '[class*="yabo"]',
    //'[id*="betting"]',
    '[href*="bet"]:not([href^="/"])',
    '[class*="regional"]',
    '[class*="world"]',
    '[class*="accumulator"]',
    '[class*=bg-sidebar]',
    '[class*=match-fixture]',
    '[class*=skins-partner-wrapper]',
    '[class*=skin-bottom]',
    //'a:not([href^="/"]):not([href^="https://www.hltv.org/"]):not([href^="http://www.hltv.org/"])',
    '[data-link-tracking-page="Widget"]',
    '[class*="widget"]',
    '[rel="nofollow"]:not([data-tooltip-id^="uid"])',
    '[class^="column-"]:not([class*="col-box"])'
];

function removeBackgroundAds() {
    document.body.removeAttribute("data-href");
    document.body.removeAttribute("style");

    // Set background to bar Color
    $(document.body).css("background-color", $(".navbar").css("background-color"));
}

function removeTopAds() {
    var topDiv = document.getElementsByClassName("logoCon")[0];
    if (topDiv == null) return;
    var adCount = topDiv.children.length - 1;

    while (adCount > 0) {
        topDiv.removeChild(topDiv.lastElementChild);
        adCount--;
    }
}

removeTopAds();
removeBackgroundAds();

// Set a loop to avoid cleaning failed when loading problem occurs
let topAdsInterval = setInterval(removeTopAds, 250);
let backgroundAdsInterval = setInterval(removeBackgroundAds, 250);

setTimeout(function() {
    clearInterval(topAdsInterval);
    clearInterval(backgroundAdsInterval);
    console.log("Sick Ilya! Let's fucking Go!😂");
}, 5000);


// Use ADBlock way to block some annoy element
(function removeFilters() {
    var $hiddenStyle = $('<style type="text/css"></style>');
    $($('head')[0]).append($hiddenStyle);
    $hiddenStyle.append(filters + "{display: none !important; visibility: hidden !important;}");
})();

const hiddenStyle = document.createElement("style")
hiddenStyle.innerText = "#betting {display: none}"
document.head.appendChild(hiddenStyle)