YouTube - Play Watch Later Videos Outside of Water Later Playlist

Removes query parameters related to Water Later Playlist in YouTube URLs. 14/12/2024, 12:02:46 pm

// ==UserScript==
// @name        YouTube - Play Watch Later Videos Outside of Water Later Playlist
// @namespace   YouTube-PlayWatchLaterVideosOutsideofWaterLaterPlaylist
// @match       https://www.youtube.com/watch*
// @grant       none
// @version     1.0
// @author      EL
// @description Removes query parameters related to Water Later Playlist in YouTube URLs. 14/12/2024, 12:02:46 pm
// @license     MIT
// ==/UserScript==

(function() {
  'use strict';

  // Parse the current URL
  var currentUrl = new URL(window.location.href);

  // Check if "list=WL" exists in the query parameters
  if (currentUrl.searchParams.get("list") === "WL") {
    // Remove the "list" parameter
    currentUrl.searchParams.delete("list");

    // Remove the "index" parameter if it exists
    currentUrl.searchParams.delete("index");

    // Remove the "pp" parameter if it exists
    currentUrl.searchParams.delete("pp");

    // Only redirect if the URL has changed
    if (currentUrl.href !== window.location.href) {
      window.location.assign(currentUrl.href);
    }
  }
})();