From b74c26ed01640db4f6d0a06f67d6e25627fb07be Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Thu, 2 Jan 2020 00:08:38 +0100
Subject: [PATCH] Add 'Block YouTube Playlists'

---
 YouTube/BlockPlaylists.user.js | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 YouTube/BlockPlaylists.user.js

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);