javascript:(function(){var%20collection%20%3D%20%5B%5D%3B%0Avar%20page%20%3D%201%3B%0Awhile%20(page%20%3E%200)%20%7B%0A%09%24.ajax(%7B%0A%09%09%20async%3A%20false%2C%0A%09%09%20type%3A%20'GET'%2C%0A%09%09%20url%3A%20window.location.href.replace(%2F(%5Cd%2B)%24%2F%2Cpage)%2C%0A%09%09%20success%3A%20function(data)%20%7B%0A%09%09%20%09%24data%20%3D%20%24(data)%3B%0A%09%09%09var%20epTitle%20%3D%20%24data.find('%23episode%20h2').first().text()%3B%0A%09%09%09var%20output%20%3D%20'%23%23%23%20%23'%2Bpage%2B'%3A%20'%2BepTitle%2B%22%5Cn%5Cn%22%3B%0A%09%09%09output%20%2B%3D%20'%5B**%5BShow%20link%5D('%2Bwindow.location.href.replace(%2F%5Cd%2B%24%2F%2Cpage)%2B%22)**%5D%5Cn%5Cn%22%0A%09%09%09%24data.find('%23episode_links').find('a').each(function()%7B%20output%20%2B%3D%20%22*%20%5B%22%2B%24(this).text().replace(%2F%5C%7C%2Fg%2C'-').replace(%2F%5B%5C%5B%5C%5D%5D%5D%2Fg%2C'**')%2B%22%5D(%22%2B%24(this).attr('href')%2B%22)%5Cn%22%20%7D)%3B%0A%09%09%09collection.push(output)%3B%0A%09%09%09page%20%2B%3D%201%3B%0A%09%09%20%7D%2C%0A%09%09%20error%3A%20function(data)%20%7B%0A%09%09%09page%20%3D%20-1%3B%0A%09%09%20%7D%0A%09%7D)%3B%0A%7D%0A%24('%3Cdiv%3E').css(%7B%0A%09position%3A'fixed'%2C%0A%09top%3A%20'0'%2C%0A%09left%3A'0'%2C%0A%09right%3A'0'%2C%0A%09bottom%3A'0'%2C%0A%09overflow%3A'auto'%2C%0A%09backgroundColor%3A'%23efefef'%2C%0A%09color%3A'%23333'%2C%0A%09zIndex%3A'99999'%7D).append(%24('%3Cpre%20id%3D%22eplinkoutput%22%3E').css('padding'%2C'20px').text(collection.join(%22%5Cn%22))).appendTo('body')%0A%09.click(function()%20%7B%0A%09%09var%20doc%20%3D%20document%2C%20text%20%3D%20doc.getElementById('eplinkoutput')%2C%20range%2C%20selection%3B%0A%09%09if%20(doc.body.createTextRange)%20%7B%0A%09%09%09range%20%3D%20doc.body.createTextRange()%3B%0A%09%09%09range.moveToElementText(text)%3B%0A%09%09%09range.select()%3B%0A%09%09%7D%20else%20if%20(window.getSelection)%20%7B%0A%09%09%09selection%20%3D%20window.getSelection()%3B%0A%09%09%09range%20%3D%20doc.createRange()%3B%0A%09%09%09range.selectNodeContents(text)%3B%0A%09%09%09selection.removeAllRanges()%3B%0A%09%09%09selection.addRange(range)%3B%0A%09%09%7D%0A%09%7D)%3B%0A}());
Last active
December 12, 2015 09:19
-
-
Save ttscoff/4750183 to your computer and use it in GitHub Desktop.
Generates a Markdown list of all the show links for a 5by5 show. Start it on the page for the first episode. Click the results once to select all for copying.
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
// generates a Markdown list of all the show links for a 5by5 show. Click the results to select all for copying. | |
// only designed for 5by5, which already has jQuery loaded and matches the regex. Customize as needed for other uses. | |
// Brett Terpstra 2013 | |
var collection = []; | |
var page = 1; | |
while (page > 0) { | |
$.ajax({ | |
async: false, | |
type: 'GET', | |
url: window.location.href.replace(/(\d+)$/,page), | |
success: function(data) { | |
$data = $(data); | |
var epTitle = $data.find('#episode h2').first().text(); | |
var output = '### #'+page+': '+epTitle+"\n\n"; | |
output += '[**[Show link]('+window.location.href.replace(/\d+$/,page)+")**]\n\n" | |
$data.find('#episode_links').find('a').each(function(){ output += "* ["+$(this).text().replace(/\|/g,'-').replace(/[\[\]]]/g,'**')+"]("+$(this).attr('href')+")\n" }); | |
collection.push(output); | |
page += 1; | |
}, | |
error: function(data) { | |
page = -1; | |
} | |
}); | |
} | |
$('<div>').css({ | |
position:'fixed', | |
top: '0', | |
left:'0', | |
right:'0', | |
bottom:'0', | |
overflow:'auto', | |
backgroundColor:'#efefef', | |
color:'#333', | |
zIndex:'99999'}).append($('<pre id="eplinkoutput">').css('padding','20px').text(collection.join("\n"))).appendTo('body') | |
.click(function() { | |
var doc = document, text = doc.getElementById('eplinkoutput'), range, selection; | |
if (doc.body.createTextRange) { | |
range = doc.body.createTextRange(); | |
range.moveToElementText(text); | |
range.select(); | |
} else if (window.getSelection) { | |
selection = window.getSelection(); | |
range = doc.createRange(); | |
range.selectNodeContents(text); | |
selection.removeAllRanges(); | |
selection.addRange(range); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment