Created
November 6, 2016 23:33
-
-
Save Scarsz/6faa65cf74e5702c4266343fa04c8adb to your computer and use it in GitHub Desktop.
JavaScript bookmarklet to get links to all imgs on the current page and optionally download them
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
(function() { | |
var images = [].slice.call(document.querySelectorAll('img')); | |
var urls = []; | |
images.forEach(function(img) { | |
if (!urls.includes(img.src)) urls.push(img.src); | |
}); | |
if (confirm("Download all the things?")) { | |
var link = document.createElement('a'); | |
link.setAttribute('download', ''); | |
urls.forEach(function(img) { | |
link.setAttribute('href', img); | |
link.click(); | |
}); | |
} | |
var x = document.createElement("TEXTAREA"); | |
var t = document.createTextNode(urls.join("\r\n")); | |
x.appendChild(t); | |
document.body.appendChild(x); | |
}).call(window); |
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
javascript:;(function() { var images = [].slice.call(document.querySelectorAll('img')); var urls = []; images.forEach(function(img) { if (!urls.includes(img.src)) urls.push(img.src); }); if (confirm("Download all the things?")) { var link = document.createElement('a'); link.setAttribute('download', ''); urls.forEach(function(img) { link.setAttribute('href', img); link.click(); }); } var x = document.createElement("TEXTAREA"); var t = document.createTextNode(urls.join("\r\n")); x.appendChild(t); document.body.appendChild(x);}).call(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment