Last active
November 8, 2017 02:30
-
-
Save malikbenkirane/742f6b52870869868e9176a8e8fe5e02 to your computer and use it in GitHub Desktop.
Inject me on discogs.com pages with iframe#youtube_player_placeholder & then use your favorite playlist players
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var test = "iframe#youtube_player_placeholder"; | |
function parseyt(iframe_selector) { | |
var take = document.querySelector(iframe_selector).src.split('%2C'); | |
var list = []; | |
list[0] = take[0].match("playlist=(.{11})")[1]; | |
for ( var i = 1 ; i < take.length - 1 ; i++ ) { | |
list[i] = take[i]; | |
} | |
list[list.length] = take[list.length].split('&')[0]; | |
return list; | |
} | |
function m3u(iframe_selector) { | |
m3u_string = ''; | |
list = parseyt(iframe_selector); | |
list.forEach(function(videoId) { | |
m3u_string += 'https://youtube.com/watch?v=' + videoId + '\n'; | |
}) | |
return m3u_string; | |
} | |
try { | |
m3u(test); | |
} catch (e) { | |
console.log('debug :)'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment