Greasy Fork

屏蔽谷歌广告

自动屏蔽谷歌广告的插件,告别烦恼!!!

当前为 2023-07-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         屏蔽谷歌广告
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动屏蔽谷歌广告的插件,告别烦恼!!!
// @author       Boen
// @match        *://*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=231395.com
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  "use strict";
  const adSelectArr = ["ins", `[id*="aswift"]`]; // ad's selectors

  // remove ad
  function removeADs(adSelectArr) {
    for (const el of adSelectArr) {
      const adIns = document.querySelectorAll(el);
      if (adIns) {
        for (let el of adIns) {
          try {
            el && el.remove();
          } catch (error) {}
        }
      }
    }
  }
  setTimeout(() => {
    removeADs(adSelectArr);
  }, 200);
})();