YouTube Url Remove PP

To remove "pp=" in YouTube Url

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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);
  }

})();