diff --git a/YouTube/BlockPlaylists.user.js b/YouTube/BlockPlaylists.user.js new file mode 100644 index 0000000..554d4d9 --- /dev/null +++ b/YouTube/BlockPlaylists.user.js @@ -0,0 +1,30 @@ +// ==UserScript== +// @name Block YouTube Playlists +// @description Removes playlists from YouTube video URLs. +// @version 1 +// @license MPL-2.0 +// @namespace https://chylex.com +// @homepageURL https://github.com/chylex/Userscripts +// @supportURL https://github.com/chylex/Userscripts/issues +// @include https://youtube.com/* +// @include https://*.youtube.com/* +// @run-at document-start +// @grant none +// @noframes +// ==/UserScript== + +if (location.pathname == "/watch" && location.search.includes("&list=")){ + history.replaceState({}, document.title, location.search.replace(/&list=(.*)/, "")); + location.reload(); +} + +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);