Created
March 3, 2018 21:44
-
-
Save anonymous/bed3b0f92acbb70ab501c412de036bdd to your computer and use it in GitHub Desktop.
This file contains 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 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