Last active
August 29, 2015 14:01
-
-
Save daformat/cfca3b29324ac9891f19 to your computer and use it in GitHub Desktop.
Extract images from current wikipedia page to markdown.
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
(function(){ | |
var $t = $('.thumbcaption'), | |
$i =$('.image img'), | |
r="", md, i; | |
for(i=0; i < $t.length; i++){ | |
r+=("![" + $($t[i]).text().replace(/(\r\n|\n|\r)/gm,"")+"]("+$($i[i]).attr('src').replace(/(\/thumb\/)/gm, "/").replace(/\.(png|svg|jpg|jpeg|bmp|gif)\/.*$/gm, ".$1")+")\n" ) | |
} | |
md = r+'\nImages from ["'+$('#firstHeading').text()+'" on wikipedia]'+'('+document.location.href+')\n'; | |
console.log('\n\nFound '+$i.length+' image'+($i.length>1?'s':'')+', here is the markdown:\n-----\n\n'+md+'\n'); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment