YouTube Url Remove PP

To remove "pp=" in YouTube Url

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        YouTube Url Remove PP
// @namespace   UserScript
// @match       https://www.youtube.com/*
// @grant       none
// @run-at      document-start
// @version     1.0
// @author      CY Fung
// @license     MIT
// @description To remove "pp=" in YouTube Url
// ==/UserScript==

(() => {
  const Promise = ((async () => { })()).constructor;
  const ets = `
      yt-navigate
      yt-navigate-start
      yt-page-type-changed
      yt-player-updated
      yt-page-data-fetched
      yt-navigate-finish`.trim().split(/\s+/)

  const fn = () => {
    if (location.search.includes('pp=')) {
      let oUrl = location.pathname + location.search;
      let nUrl = location.pathname + location.search.replace(/([?&])pp=[^=&?]+\b(\&|)/, (a, p, q) => {
        return !q ? '' : p
      });
      if (oUrl !== nUrl) history.replaceState(history.state, '', nUrl);
    }

  }
  const fh = () => {
    fn();
    Promise.resolve().then(fn);
  }
  for (const et of ets) {

    document.addEventListener(et, fh, false);
  }

})();