您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Redirect /shorts to /watch
当前为
// ==UserScript== // @name Redirect YouTube Shorts to Watch // @namespace http://tampermonkey.net/ // @version 0.1.2 // @description Redirect /shorts to /watch // @author CY Fung // @license MIT // @run-at document-start // @match https://*.youtube.com/* // @match http://*.youtube.com/* // @match https://youtube.com/* // @match http://youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // @unwrap // @noframes // @inject-into page // ==/UserScript== (function () { 'use strict'; let lastPathname = ''; let lastId = ''; /** * * @param {Event?} evt */ function checkRedirect(evt) { let pathname = location.pathname; if (lastPathname !== pathname) { let id = ''; if (pathname && pathname.startsWith('/shorts')) { let m = /\/shorts\/([\w\-\_\+\=]+)/.exec(pathname) if (m) { id = m[1]; } } lastPathname = pathname; lastId = id; } let id = lastId; if (id) { if (evt) { evt.stopPropagation(); evt.stopImmediatePropagation(); } location.replace('/watch?v=' + id); } } for (const s of ['yt-navigate', 'yt-navigate-start', 'yt-page-data-fetched', 'yt-page-data-updated', 'yt-navigate-finish']) { document.addEventListener(s, checkRedirect, true); } checkRedirect(); // Your code here... })();