bilibili超链接不新开标签页直接在当前页面打开,外加移除下载app的广告条
< Feedback on bilibili超链接不新开标签页直接在当前页面打开
你懂代碼可以自己改吧
// ==UserScript==
// @name bilibili超链接不新开标签页直接在当前页面打开
// @namespace EtfB2XVPmbThEv39bdxQR2hzid30iMF9
// @version 0.5
// @description bilibili超链接不新开标签页直接在当前页面打开,外加移除下载app的广告条
// @author tomoya
// @include https://*.bilibili.com*
// @exclude https://t.bilibili.com*
// @exclude https://message.bilibili.com*
// @grant none
// ==/UserScript==
(function () {
'use strict';
const f = () => {
let aEles = document.querySelectorAll("a[target]");
aEles.length >= 1 && removeTarget(aEles);
let appDownloadDiv = document.getElementById("fixed_app_download");
if (appDownloadDiv) {
appDownloadDiv.parentNode.removeChild(appDownloadDiv);
}
};
let observer = new MutationObserver(function () {
Promise.resolve().then(f);
});
observer.observe(document.body, {childList: true, subtree: true});
function removeTarget(aEles) {
aEles.forEach(function (ele) {
ele.removeAttribute("target");
});
}
f();
})();
我看了源码,为什么要每0.2s运行一次呢,这样不是很浪费CPU吗