remove_redirect

remove redirects in zhihu.com

目前為 2024-10-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name         remove_redirect
// @namespace    https://github.com/mikelxk/remove_redirect
// @version      0.0.0
// @author       mikelxk
// @description  remove redirects in zhihu.com
// @license      MIT
// @icon         https://vitejs.dev/logo.svg
// @match        https://zhihu.com/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  setInterval(() => {
    let links = document.querySelectorAll("a");
    links.forEach((link) => {
      if (link.href.includes("https://link.zhihu.com/?target=")) {
        const urlParams = new URLSearchParams(link.href.split("?")[1]);
        const newLink = urlParams.get("target");
        if (newLink) {
          link.href = decodeURIComponent(newLink);
        }
      }
    });
  }, 1e3);

})();