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