Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit92e16aff09b7666ace7eafba268a711b1bf07964 (patch)
Author
 Kamen Mladenov <kamen.d.mladenov@protonmail.com>
2022-04-10 06:36:51 +0000
Committer
 Kamen Mladenov <kamen.d.mladenov@protonmail.com>
2022-04-10 06:36:51 +0000
Filesbb8e2fa9d0532e90fa45748e990beb51b1a04549
userscripts-92e16aff09b7666ace7eafba268a711b1bf07964.tar
userscripts-92e16aff09b7666ace7eafba268a711b1bf07964.tar.gz
userscripts-92e16aff09b7666ace7eafba268a711b1bf07964.zip
Parent1fe5ed9dac706702d2e696f01cde635106fa11da (diff)
Added YouTube shorts redirector script
1 files changed, 33 insertions, 0 deletions
-rw-r--r--youtube-shorts-redirector.js33
diff --git a/youtube-shorts-redirector.js b/youtube-shorts-redirector.js
new file mode 100644
index 0000000..27ed515
--- /dev/null
+++ b/youtube-shorts-redirector.js
@@ -0,0 +1,33 @@
+// ==UserScript==
+// @name YouTube shorts redirector
+// @description Redirects all youtube shorts videos to normal video pages
+// @author Kamen Mladenov
+// @match *://*.youtube.com/*
+// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Youtube_shorts_icon.svg/193px-Youtube_shorts_icon.svg.png
+// @grant none
+// @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, });