知乎优化

优化知乎体验

当前为 2022-12-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         知乎优化
// @namespace    http://tampermonkey.net/
// @version      0.2.0
// @description  优化知乎体验
// @author       share121
// @match        https://zhuanlan.zhihu.com/*/*
// @match        https://www.zhihu.com/*/*
// @icon         https://static.zhihu.com/heifetz/favicon.ico
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function () {
    "use strict";
    let tmp = setInterval(() => {
        let button = document.querySelector(".Modal-closeButton");
        if (button) {
            clearInterval(tmp);
            button.click();
        }
    }, 0);
    window.addEventListener("load", () => {
        document.querySelectorAll("a.wrap.external").forEach((e) => {
            let href = e.href;
            if (/target=([^&]+)/.test(href)) {
                e.href = decodeURIComponent(href.match(/target=([^&]+)/)[1]);
            }
        });
    });
})();