Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2018 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bed3b0f92acbb70ab501c412de036bdd to your computer and use it in GitHub Desktop.
Save anonymous/bed3b0f92acbb70ab501c412de036bdd to your computer and use it in GitHub Desktop.
var a = document.getElementsByClassName("post-wrapper");
var str_links = "";
for( var i = 0; i < a.length; i++ )
{
if( a[i].childNodes[1].childNodes[1].childNodes[1].checked )
{
var pics = a[i].getElementsByTagName('a');
for( var j = 0; j < pics.length; j++ )
{
if( pics[j].href.indexOf( "jpg" ) !== -1 ||
pics[j].href.indexOf( "png" ) !== -1 ||
pics[j].href.indexOf( "mp4" ) !== -1 ||
pics[j].href.indexOf( "gif" ) !== -1 ||
pics[j].href.indexOf( "webm" ) !== -1 )
{
str_links += pics[j].href;
str_links += "\n";
}
}
}
}
//read text from textbox placed in parent window
var text = str_links;
var textFile = null, makeTextFile = function (text)
{
var data = new Blob([text], {type: 'text/plain'});
// If we are replacing a previously generated file we need to
// manually revoke the object URL to avoid memory leaks.
if (textFile !== null)
{
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
// returns a URL you can use as a href
return textFile;
};
var pathArray = window.location.pathname.split( '/' );
var fileName = pathArray[1] + pathArray[3].split(".")[0];
var url = makeTextFile( text );
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
a.href = url;
a.download = fileName + ".txt";
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment