MCBBS 动态链接转伪静态 (支持吾爱破解)

将动态链接转为伪静态链接

目前為 2023-09-17 提交的版本,檢視 最新版本

// ==UserScript==
// @name         MCBBS 动态链接转伪静态 (支持吾爱破解)
// @namespace    https://github.com/404.html
// @version      0.4.4-fix7
// @license      AGPLv3 or later
// @description  将动态链接转为伪静态链接
// @author       axototl
// @match        *://www.mcbbs.net/*
// @match        *://www.52pojie.cn/*
// @icon         https://www.mcbbs.net/favicon.ico
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_addValueChangeListener
// @run-at       document-start
// ==/UserScript==

'use strict';

const tips = ["×定位到原贴(点击以启用)", "√定位到原贴(点击以禁用)"];
let config = {
    get sethash() {
        let tmp = GM_getValue("sethash", null);
        if (tmp === null) tmp = true, GM_setValue("sethash", true);
        return tmp;
    },
    set sethash(val) {
        GM_setValue("sethash", val);
    }
};

(function() {
    var srid = GM_registerMenuCommand(tips[config.sethash|0], changer);
    const params = new URL(location.href).searchParams;
    if (params.get("goto") == "lastpost") return;
    if (params.get("mod") == "viewthread") {
        let tid = params.get("tid");
        let page = params.get("page");
        if (!page) page = "1";
        history.replaceState(null, "", "https://"+ location.host + "/thread-"+ tid +"-"+ page +"-1.html"+ (config.sethash ? location.hash : ""));
    } else if (params.get("id") == "link_redirect") // skip alert.
        location.assign(params.get("target"));
    GM_addValueChangeListener("sethash", (_1, _2, nv) => GM_registerMenuCommand(tips[nv | 0], changer));
    function changer(){
        config.sethash = !config.sethash;
        GM_unregisterMenuCommand(srid);
        srid = GM_registerMenuCommand(tips[config.sethash|0], changer);
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址