1
0
mirror of https://github.com/chylex/Userscripts.git synced 2025-05-23 03:34:03 +02:00

Update 'Block YouTube Playlists' to work during all navigation

This commit is contained in:
chylex 2025-03-24 00:39:14 +01:00
parent 1bf299d4fe
commit 98097ef8c1
Signed by: chylex
SSH Key Fingerprint: SHA256:WqM8X/1DDn11LbYM0H5wsqZUjbcKxVsic37L+ERcF4o

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Block YouTube Playlists // @name Block YouTube Playlists
// @description Removes playlists from YouTube video URLs. // @description Removes playlists from YouTube video URLs.
// @version 1 // @version 2
// @license MPL-2.0 // @license MPL-2.0
// @namespace https://chylex.com // @namespace https://chylex.com
// @homepageURL https://github.com/chylex/Userscripts // @homepageURL https://github.com/chylex/Userscripts
@ -13,18 +13,11 @@
// @noframes // @noframes
// ==/UserScript== // ==/UserScript==
if (location.pathname == "/watch" && location.search.includes("&list=")){ function redirectPlaylist() {
history.replaceState({}, document.title, location.search.replace(/&list=(.*)/, "")); if (location.pathname === "/watch" && location.search.includes("&list=")) {
location.reload(); location.replace(location.href.replace(/&list=(.*)/, ""));
}
} }
document.addEventListener("spfclick", function(e){ redirectPlaylist();
var url = e.detail.url; document.addEventListener("yt-navigate-start", redirectPlaylist);
if (url.includes("youtube.com/watch?") && url.includes("&list=")){
// forces a normal page load
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
}
}, true);