Last active
September 27, 2015 00:44
-
-
Save KoRMaK/2df0841fe53c80a2c312 to your computer and use it in GitHub Desktop.
A script to copy and paste into your browser console to grab all the titles and links that make up the current playlist
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
| //wirtten by kormak DO NOT STEAL distrubted free as in free speach, not free burgs heuheuh | |
| // https://gist.github.com/KoRMaK/2df0841fe53c80a2c312 | |
| //runs through the playlist and grabs all the urls and stash them in an array. also outputs | |
| //their address to the console for easy copy and paste | |
| playlist_urls = [] | |
| //cool oneliner. thanks spacecheif, thpeif | |
| $.each(pl, function(i, v) {playlist_urls.push( (v.video_provider == "vm" ? "http://www.vimeo.com/" : "http://www.youtube.com/watch/") + v.video_id + " : " + v.title );}) | |
| console.log(playlist_urls.join("\n")); //throw them all to the console | |
| // old, big loop. use the oneliner instead | |
| /* | |
| playlist_urls = [] | |
| for(var _i = 0; _i < pl.length; _i++) | |
| { | |
| provider_url = ""; | |
| var i = pl[_i]; | |
| pl[0].video_id | |
| if(i["video_provider"] == "yt") | |
| provider_url = "http://www.youtube.com/watch/" + i["video_id"]; | |
| if(i["video_provider"] == "vm") | |
| provider_url = "http://www.vimeo.com/" + i["video_id"]; | |
| if(i["video_provider"] == "dm") | |
| provider_url = "http://www.dailymotion.com/video/" + i["video_id"]; | |
| if(i["video_provider"] == "lv") | |
| provider_url = "http://www.livestream.com/" + i["video_id"]; | |
| if(i["video_provider"] == "tw") | |
| provider_url = "http://www.twitch.tv/" + i["video_id"]; | |
| if(i["video_provider"] == "jtv") | |
| provider_url = "http://www.justin.tv/" + i["video_id"]; | |
| playlist_urls.push(provider_url); | |
| } | |
| console.log(playlist_urls.join("\n")); //throw them all to the console | |
| */ |
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
| // ==UserScript== | |
| // @name goontube playlist scraper | |
| // @namespace http://use.i.E.your.homepage/ | |
| // @version 0.1 | |
| // @description enter something useful | |
| // @match http://www.goontu.be/ | |
| // @match http://www.goontu.be/# | |
| // @match *goontu.be/* | |
| // @match http://goontu.be/# | |
| // @copyright 2015+, kormak | |
| // ==/UserScript== | |
| (function () { | |
| var jA = document.createElement('script'); | |
| jA.setAttribute('type', 'text/javascript'); | |
| jA.setAttribute('src', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'); | |
| document.body.appendChild(jA); | |
| //$('head').append('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" type="text/css" />'); | |
| //save_playlist_to_cookie(); | |
| setInterval(save_playlist_to_cookie, 5000); | |
| $("#fullscreentog").after('<a id="dump_playlist"><span class="st-room-link st-room-link-live"><i class="fa fa-beer fa-fw"></i></span></a>'); | |
| $("#banner").css("background-color", "#222"); | |
| $('body').css("background-color", "#222"); | |
| $("#dump_playlist").click(function(){ | |
| dump_playlist(); | |
| }); | |
| }() | |
| ); | |
| unsafeWindow.playlist_urls = [] | |
| function uniquify(collection){ | |
| unique_collection = []; | |
| old_collection = []; | |
| $.each(collection, function(index, value) { | |
| old_collection.push(JSON.stringify(value)); | |
| }); | |
| $.each(old_collection, function(index, value) { | |
| if ($.inArray(value, unique_collection)==-1) { | |
| unique_collection.push(value); | |
| } | |
| }); | |
| restored_collection = []; | |
| $.each(unique_collection, function(index, value) { | |
| restored_collection.push(JSON.parse(value)); | |
| }); | |
| return restored_collection; | |
| } | |
| unsafeWindow.uniquify = uniquify; | |
| function save_playlist_to_cookie() | |
| { | |
| dump_playlist(); | |
| var playlist_urls_stringified = JSON.stringify(playlist_urls); | |
| //first off, read the cookie | |
| stashed_infos = get_local_storage("gtub_stashed_playlist_infos") | |
| if(stashed_infos == "" || stashed_infos == null){ | |
| stashed_playlist_info = []; | |
| }else{ | |
| stashed_playlist_info = JSON.parse(stashed_infos); | |
| } | |
| //stashed_playlist_info = JSON.parse(get_cookie("gtub_stashed_playlist_infos")); | |
| complete_playlist_info = $.merge(stashed_playlist_info, playlist_urls); | |
| complete_playlist_info = uniquify(complete_playlist_info); | |
| playlist_urls_stringified = JSON.stringify(complete_playlist_info); | |
| set_local_storage("gtub_stashed_playlist_infos", playlist_urls_stringified); | |
| return playlist_urls_stringified; | |
| } | |
| unsafeWindow.save_playlist_to_cookie = save_playlist_to_cookie; | |
| //JSON.stringify(JSON.parse(get_cookie("gtub_stashed_playlist_infos"))[9]) == JSON.stringify(JSON.parse(get_cookie("gtub_stashed_playlist_infos"))[0]) | |
| function dump_playlist(){ | |
| //cool oneliner. thanks spacecheif, thpeif | |
| $.each(pl, function(i, v) { | |
| _info = [(v.video_provider == "vm" ? "http://www.vimeo.com/" : "http://www.youtube.com/watch/") + v.video_id, v.title, v.dur/60000]; | |
| playlist_urls.push(_info); | |
| }) | |
| var playlist_urls_text = playlist_urls.join("<br />"); | |
| } | |
| unsafeWindow.dump_playlist = dump_playlist; | |
| function dump_playlist_to_console(){ | |
| save_playlist_to_cookie(); | |
| stashed_infos = get_local_storage("gtub_stashed_playlist_infos") | |
| if(stashed_infos == ""){ | |
| stashed_playlist_info = []; | |
| }else{ | |
| stashed_playlist_info = JSON.parse(stashed_infos); | |
| } | |
| playlist_urls_text = ""; | |
| $.each(stashed_playlist_info, function(i, value){ | |
| playlist_urls_text += value.join(" - ") + "\n"; | |
| }); | |
| //var playlist_urls_text = stashed_playlist_info.join("<br />"); | |
| console.log(playlist_urls_text); | |
| } | |
| unsafeWindow.dump_playlist_to_console = dump_playlist_to_console; | |
| function show_dumped_playlist(){ | |
| var modal_content = "" + | |
| "<div class='modal-dialog' role='document'>" + | |
| "<div class='modal-content'>" + | |
| "<div class='modal-header'>" + | |
| "<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button>" + | |
| "<h4 class='modal-title' id=''>Playlist</h4>" + | |
| "</div>" + | |
| "<div class='modal-body'>" + | |
| "</div>" + | |
| "<div class='modal-footer'>" + | |
| "<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>" + | |
| "</div>" + | |
| "</div>" + | |
| "</div>"; | |
| video_list_modal = $('<div class="modal wide fade" id="video_listM" tabindex="-1" role="dialog"></div>').appendTo("body"); | |
| video_list_modal = video_list_modal.modal({show: true, backdrop: 'static'}); | |
| video_list_modal.html(modal_content); | |
| $(".modal-body", video_list_modal).first().html(playlist_urls_text); | |
| } | |
| unsafeWindow.show_dumped_playlist = show_dumped_playlist; | |
| function set_cookie(name, value, days) { | |
| /* This function is building the contents that will create the cookie. The if statement is checking to see if "days" has a value, | |
| if so, it is calculating the expiration date for the cookie. If "days" does not have a value, the cookie is set to expire when the | |
| browser closes. | |
| Once the expiration is calculated the cookie is created by adding name, value, and calculated expiration(expires) */ | |
| if (days) { | |
| var date = new Date(); | |
| date.setTime(date.getTime()+(days*24*60*60*1000)); | |
| // this equation converts the days variable into milliseconds days(variable)*24(hours in a day)*60(minutes in an hour)*60(seconds in | |
| //a minute)*1000(miliseconds in a second) and adds that value to the current datetime | |
| var expires = "; expires="+date.toGMTString(); | |
| } | |
| else { | |
| var expires = ""; | |
| } | |
| document.cookie = name+"="+value+expires; | |
| } | |
| unsafeWindow.set_cookie = set_cookie; | |
| function get_cookie(existing_name) { | |
| // This function takes the cookies and turns them into an array, then compares cookie names to the variable existing_name. If there is | |
| //a match between cookie and existing_name then the function saves that cookie and value to output. If no cookie exists the default output | |
| //value of "" is retained. The variable output is then returned | |
| var existing_cookie = existing_name + "="; | |
| var cookies = document.cookie.split(';'); | |
| var output = ""; | |
| for(var i=0; i<cookies.length; i++) {//loops through the array cookies | |
| var cookie = cookies[i];// setting the current cookies array item to cookie | |
| while (cookie.charAt(0)==' ') {// checks if first character in variable cookie is a space | |
| cookie = cookie.substring(1);//removes leading space from the variable cookie | |
| } | |
| if (cookie.indexOf(existing_cookie) == 0) { //checks if variable exisiting_cookie is the first character in the variable cookie | |
| output = cookie.substring(existing_cookie.length,cookie.length); | |
| } | |
| } | |
| return output; | |
| } | |
| unsafeWindow.get_cookie = get_cookie; | |
| function set_local_storage(name, value){ | |
| return localStorage.setItem(name, value); | |
| } | |
| unsafeWindow.set_local_storage = set_local_storage; | |
| function get_local_storage(name){ | |
| return localStorage.getItem(name); | |
| } | |
| unsafeWindow.get_local_storage = get_local_storage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment