Skip to content

Instantly share code, notes, and snippets.

@Dobby233Liu
Last active January 15, 2025 16:37
Show Gist options
  • Save Dobby233Liu/d4c9b37a81320df59fa23ba86f50f8be to your computer and use it in GitHub Desktop.
Save Dobby233Liu/d4c9b37a81320df59fa23ba86f50f8be to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 跳转到opus/t页面
// @namespace https://dobby233liu.github.io
// @version v1.0.1
// @description 更换动态页界面类型
// @author Liu "Dobby233Liu" Wenyuan
// @match https://t.bilibili.com/*
// @match https://www.bilibili.com/opus/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant none
// @run-at context-menu
// @homepageURL https://gist.github.com/Dobby233Liu/d4c9b37a81320df59fa23ba86f50f8be
// @supportURL https://gist.github.com/Dobby233Liu/d4c9b37a81320df59fa23ba86f50f8be#comments
// @downloadURL https://gist.github.com/Dobby233Liu/d4c9b37a81320df59fa23ba86f50f8be/raw/switch-between-dynamic-page-mode.user.js
// @updateURL https://gist.github.com/Dobby233Liu/d4c9b37a81320df59fa23ba86f50f8be/raw/switch-between-dynamic-page-mode.user.js
// ==/UserScript==
(function() {
"use strict";
let newURL = new URL(location.href);
let unrecongizedPath = true;
switch (location.hostname) {
case "t.bilibili.com":
if (location.pathname.match(/^\/[0-9]+$/)) {
newURL.hostname = "www.bilibili.com";
newURL.pathname = "/opus" + newURL.pathname;
unrecongizedPath = false;
}
break;
case "www.bilibili.com":
if (location.pathname.match(/^\/opus\/[0-9]+$/)) {
newURL.hostname = "t.bilibili.com";
newURL.pathname = newURL.pathname.replace(/^\/opus/, "");
unrecongizedPath = false;
}
break;
}
if (!unrecongizedPath) {
location.href = newURL.href;
} else {
alert("不支持此路径");
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment