// ==UserScript== // @license MIT // @name 屏蔽芊芊经典广告被拦截后的框架 // @namespace http://tampermonkey.net/ // @version 0.5 // @description 芊芊经典广告被拦截后会弹出一个框架,屏蔽的框架 // @author Tenfond // @match *://myqqjd.com/* // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; let NoBlurStyle = document.createElement("style"); NoBlurStyle.innerHTML = "" + "body > *:not(#wpadminbar):not(.afsuo-cagwq-modal):not(.afsuo-cagwq-wrapper):not(.afsuo-cagwq-blackout) {\n" + " -webkit-filter: blur(0px);\n" + " filter: blur(0px);\n" + "}\n" + ".adsbygoogle {\n" + " display: none;\n" + " width: 0px;\n" + " height: 0px;\n" + "}\n" + "aside[id^=advert] {\n" + " display: none;\n" + " height: 0;\n" + " width: 0;\n" + "}"; document.head.insertBefore(NoBlurStyle, document.head.firstChild); // 以下代码没有效果 /* document.oncontextmenu = function (event) { // 开启右键 event.returnValue = true; } document.onselectstart = function (event) { // 开启选中文字 event.returnValue = true; } document.ondragstart = function (event) { // 允许拖拽图片 event.returnValue = true; } document.oncopy = function (event) { // 允许复制 event.returnValue = true; }*/ doElementAll("aside[id^=advert]", function (ADaside) { for (let i = 0; i < ADaside.length; i++) { ADaside[i].style = "display: none; height: 0; width: 0;"; } }, 5000); doElementAll("body>div[class$=-wrapper]", function (wrapper) { let displayClassNameFirst = wrapper[0].className.match(/([\w-]+)-wrapper/)[1]; doElementAll("body>div." + displayClassNameFirst + "-blackout.active,body>div." + displayClassNameFirst + "-modal.active", function (element) { wrapper[0].style = "display: none; height: 0; width: 0;"; element[0].style = "display: none; height: 0; width: 0;"; document.body.classList.remove(displayClassNameFirst + "-blur"); }) }, 5000); function doElementAll(cssString, doFunction, waitMS = 0) { let Elements = document.querySelectorAll(cssString); if (Elements[0].nodeType === 1) { doFunction(Elements); console.log("已为 " + cssString + " 进行了操作"); } else if (document.readyState !== "complete" || waitMS > 0) { console.log("正在查找 " + cssString); setTimeout(function () { doElementAll(cssString, doFunction, document.readyState !== "complete" ? waitMS : waitMS - 310); // TODO 10毫秒约函数执行时间 }, 300); } else { console.log("%c未找到 " + cssString, 'color: #f00;'); } } })();