summaryrefslogtreecommitdiff
path: root/yt_noplaylist.user.js
blob: 59bd71a5b571110324dcef3eb99479c97fde1ee9 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// ==UserScript==
// @name         YouTube No Playlist
// @namespace    https://git.xservers.dy.fi/cgit.cgi/stderr64/yt_noplaylist
// @version      1.0
// @description  Redirect youtube playlist to non-playlist url
// @author       stderr64
// @match        https://www.youtube.com/watch?v=*&list=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

		if ( window.location === undefined || window.location.length === 0 ){
			console.log( "[YouTube No Playlist] Error: window.location is undefined or empty" );
			return;
		}
		var win_location_str = window.location.toString();
		if ( !win_location_str.match(/\/watch\?v=\w+&list=\w+$/) ){
			return;
		}
		var win_location_split = win_location_str.split( "&list=" );
		if ( win_location_split.length === 0 ){
			return;
		}
		if ( win_location_split[1].length === 0 || !win_location_split[1].match(/\w+$/) ){
			return;
		}
		window.location.assign( win_location_split[0] );
		return;
})();