Shellshock.io Ad Blocker

Blocks ads on Shellshock.io

目前為 2024-09-03 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Shellshock.io Ad Blocker
// @namespace    https://shellshock.io
// @description  Blocks ads on Shellshock.io
// @version      1.2
// @match        https://shellshock.io/*
// @license MIT
// ==/UserScript==

(function() {
  'use strict';

  // Function to remove the ad blocker warning element
  function removeAdBlockerWarning() {
    var adBlockerWarning = document.getElementById('adBlockerVideo');
    if (adBlockerWarning) {
      adBlockerWarning.parentNode.removeChild(adBlockerWarning);
    }
  }

  // Function to prevent ads from being loaded
  function blockAds() {
    var aiptag = window.aiptag;
    if (aiptag) {
      aiptag.cmd = [];
      aiptag.cmd.display = [];
      aiptag.cmd.player = [];
    }
  }

  // Observe the document for changes to detect when the ad blocker warning element is created
  var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
      if (mutation.addedNodes && mutation.addedNodes.length > 0) {
        for (var i = 0; i < mutation.addedNodes.length; i++) {
          var node = mutation.addedNodes[i];
          if (node.id === 'adBlockerVideo') {
            removeAdBlockerWarning();
          }
        }
      }
    });
  });

  // Configure the observer to observe the document for changes
  observer.observe(document, {
    childList: true,
    subtree: true
  });

  // Block ads immediately
  blockAds();

  // Block ads whenever the aiptag object is updated
  setInterval(blockAds, 1000);
})();