您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Redirects /shorts/{videoId} -> /watch?v={videoId}
- // ==UserScript==
- // @name YouTube Shorts Redirect
- // @version 2.0
- // @description Redirects /shorts/{videoId} -> /watch?v={videoId}
- // @author aubymori
- // @match www.youtube.com/*
- // @namespace aubymori.github.io
- // @icon https://www.youtube.com/favicon.ico
- // @run-at document-start
- // @grant none
- // ==/UserScript==
- (function(){
- // Softload
- function redirectShorts(e) {
- if (e.detail.pageData.page == 'shorts') {
- var videoId = e.detail.pageData.endpoint.reelWatchEndpoint.videoId;
- document.querySelector('ytd-navigation-manager').dispatchEvent(
- new CustomEvent('yt-navigate', {
- 'bubbles': true,
- 'detail': {
- 'endpoint': {
- 'commandMetadata': {
- 'webCommandMetadata': {
- 'pageType': 'WEB_PAGE_TYPE_WATCH',
- 'url': '/watch?v=' + videoId
- },
- },
- 'watchEndpoint': {
- 'videoId': videoId
- }
- }
- }
- })
- );
- // Player dies for some reason
- document.getElementById('movie_player').loadVideoById(videoId);
- }
- }
- document.addEventListener('yt-page-data-fetched', redirectShorts);
- // On initial load
- if (window.location.pathname.search('/shorts/') > -1) {
- window.location.replace('https://www.youtube.com/watch?v=' + /[^/]*$/.exec(location.href));
- }
- })();