您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
PTT 網頁 404 的時候 導頁到 PTTWeb
// ==UserScript== // @name PTT 404 Redirect to PTTWeb // @namespace https://github.com/livinginpurple // @version 2023.01.31.01 // @description PTT 網頁 404 的時候 導頁到 PTTWeb // @license WTFPL // @author livinginpurple // @match https://*.ptt.cc/* // @run-at document-start // @grant none // @grant GM.xmlHttpRequest // ==/UserScript== (function() { 'use strict'; const scriptName = GM_info.script.name; console.log(`${scriptName} is loading.`); function urlExists(url, callback) { fetch(url, { method: 'head' }) .then(function (status) { callback(status.ok) }); } let url = document.location.href; urlExists(url, function (exists) { if (exists) { // it exists, do something } else { location.href = url.replace('ptt', 'pttweb'); } }); console.log(`${scriptName} is running.`); })();