您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
PTT相關網站,自動轉跳到 www.pttweb.cc
// ==UserScript== // @name PTT 相關網站自動轉址到 pttweb.cc // @namespace http://tampermonkey.net/ // @version 0.2 // @description PTT相關網站,自動轉跳到 www.pttweb.cc // @author RzChan // @match *://www.ptt.cc/bbs/* // @match *://ptthito.com/* // @match *://disp.cc/b/* // @icon https://www.google.com/s2/favicons?domain=ptt.cc // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; const doRedirect = () => { let pathname = window.location.pathname; switch (window.location.host) { case "www.ptt.cc": { break; } case "ptthito.com": { pathname = pathname.replaceAll("-", "."); const secondPathReg = new RegExp(/(?<=\/.+\/.*).+(?=.*\/)/g); const secondPath = secondPathReg.exec(pathname)[0]; pathname = pathname.replace(/(?<=\/.+\/.*).+(?=.*\/)/g, secondPath.toUpperCase()) pathname = pathname.replace(/\/$/g, ""); pathname = `/bbs${pathname}`; break; } case "disp.cc": { const linkElement = document.evaluate("//span[contains(text(),'※ 文章網址: ')]/a", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; if (linkElement !== null) { const link = linkElement.href; link = link.replace("www.ptt.cc", "www.pttweb.cc"); window.location.href = link; } return; } } window.location.href = `https://www.pttweb.cc${pathname}`; } doRedirect(); })();