remove redirects in zhihu.com
当前为
// ==UserScript==
// @name remove_redirect
// @namespace https://github.com/mikelxk/remove_redirect
// @version 0.0.1
// @author mikelxk
// @description remove redirects in zhihu.com
// @license MIT
// @icon https://vitejs.dev/logo.svg
// @match *://*.zhihu.com/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
let prevCnt = 0;
setInterval(() => {
let links = document.querySelectorAll("a");
let newCnt = links.length;
if (newCnt === prevCnt) {
prevCnt = newCnt;
return;
}
prevCnt = newCnt;
links.forEach((link) => {
if (link.href.includes("https://link.zhihu.com/?target=") || link.href.includes("http://link.zhihu.com/?target=")) {
const urlParams = new URLSearchParams(link.href.split("?")[1]);
const newLink = urlParams.get("target");
if (newLink) {
link.href = decodeURIComponent(newLink);
}
}
});
}, 1e3);
})();