Redirect-Shorts

Redirect to watch page

À partir de 2023-05-04. Voir la dernière version.

// ==UserScript==
// @name        Redirect-Shorts
// @namespace   https://github.com/sapondanaisriwan/anti-shorts
// @match       https://www.youtube.com/*
// @grant       none
// @version     1.0.2
// @author      sapondanaisriwan
// @description Redirect to watch page
// @license      MIT
// @run-at      document-start
// @icon        https://user-images.githubusercontent.com/64634605/235854015-81c5986d-b858-4f64-b14c-93bba56ba265.png
// ==/UserScript==

"use strict";

function redirectToWatchPage() {
  const { origin, pathname } = location;
  const isShorts = pathname.startsWith("/shorts/");
  const newURL = `${origin}${pathname.replace("shorts", "watch")}`;
  isShorts && location.replace(newURL);
}

function run() {
  redirectToWatchPage();
  document.addEventListener("yt-navigate-start", redirectToWatchPage);
}

run();