您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Detects 404/Not Found pages and redirects to the archived version on archive.org
// ==UserScript== // @name 404 to Archive Redirecter // @namespace http://tampermonkey.net/ // @version 0.2 // @description Detects 404/Not Found pages and redirects to the archived version on archive.org // @author Patryk Kordisch // @match *://*/* // @run-at document-end // @exclude *://web.archive.org/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function is404Page() { // Check HTTP Status Code using Performance API const navEntries = window.performance.getEntriesByType('navigation'); if (navEntries.length > 0 && navEntries[0].responseStatus === 404) { return true; } return false; } // Confirmation dialog function offerRedirect(archiveUrl) { if (confirm(`This appears to be a missing page.\n\nWould you like to view an archived version?`)) { window.location.href = archiveUrl; } } // If the current page qualifies as a 404 and user confirms it, he gets redirected to the archive setTimeout(() => { if (is404Page()) { // Get URL const currentUrl = window.location.href; const archiveUrl = "https://web.archive.org/web/" + currentUrl; setTimeout(() => offerRedirect(archiveUrl), 500); } }, 2000); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址