解决知乎外链与Clickable Links拓展冲突的问题
// ==UserScript==
// @name 解决知乎外链与Clickable Links拓展冲突
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 解决知乎外链与Clickable Links拓展冲突的问题
// @author Chen
// @match https://www.zhihu.com/question/*
// @match https://zhuanlan.zhihu.com/p/*
// @grant none
// ==/UserScript==
const observedElement = [];
(function () {
'use strict';
const bodyObserver = new MutationObserver(function (mutationsList) {
observeExternal();
});
bodyObserver.observe(document.querySelector("body"), { childList: true, subtree: true });
})();
function observeExternal() {
document.querySelectorAll('.external > .visible').forEach(function (it) {
if (!observedElement.includes(it)) {
observedElement.push(it);
const externalObserver = new MutationObserver(function (mutationsList) {
const tags = it.getElementsByTagName("a")
for (let index = 0; index < tags.length; index++) {
const element = tags[index];
element.removeAttribute("href");
console.log(".external > .visible > a href removed");
}
});
externalObserver.observe(it, { childList: true });
}
});
}