blob: fcc5872cd60b80f62ca1ff6985a577695075b4f9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// ==UserScript==
// @name YouTube shorts redirector
// @description Redirects all youtube shorts videos to normal video pages
//
// @version 1.0
// @license MIT
// @author Syndamia
//
// @source https://gitlab.com/Syndamia/userscripts/-/blob/main/youtube-shorts-redirector.js
// @supportURL https://gitlab.com/Syndamia/userscripts/-/issues
// @homepage https://gitlab.com/Syndamia/userscripts/
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Youtube_shorts_icon.svg/193px-Youtube_shorts_icon.svg.png
//
// @namespace Syndamia
// @match *://*.youtube.com/*
// @run-at document-end
// ==/UserScript==
function redirect() {
if (window.location.pathname.indexOf('shorts') !== 1) {
return;
}
const loc = 'sh_' + window.location.pathname.substr(8);
if (localStorage.getItem(loc) === 'true') {
return;
}
const latest = localStorage.getItem('sh_LATEST');
if (latest) {
localStorage.removeItem(latest);
}
localStorage.setItem(loc, true);
localStorage.setItem('sh_LATEST', loc);
window.location = window.location.href.replace("youtube.com/shorts/", "youtube.com/watch?v=");
}
const observer = new MutationObserver(redirect);
observer.observe(document.getElementsByTagName('ytd-app')[0], { childList: true, attributes: true, subtree: true, });
|