Last active
June 5, 2016 17:22
-
-
Save andrzj/2018b178eda4444c604f to your computer and use it in GitHub Desktop.
Windows wallpaper download script
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 saveToDisk = function (fileURL, fileName) { | |
// for non-IE | |
if (!window.ActiveXObject) { | |
var save = document.createElement('a'); | |
save.href = fileURL; | |
save.target = '_blank'; | |
save.download = fileName || 'unknown'; | |
var event = document.createEvent('Event'); | |
event.initEvent('click', true, true); | |
save.dispatchEvent(event); | |
(window.URL || window.webkitURL).revokeObjectURL(save.href); | |
} | |
// for IE | |
else if ( !! window.ActiveXObject && document.execCommand) { | |
var _window = window.open(fileURL, '_blank'); | |
_window.document.close(); | |
_window.document.execCommand('SaveAs', true, fileName || fileURL) | |
_window.close(); | |
} | |
} | |
var elems = document.querySelectorAll('.galleryGrid .para a'); | |
for (i = 0; i < elems.length; i++) { | |
var url = elems[i].href; | |
var pathname = elems[i].pathname; | |
var filename = pathname.substr(pathname.lastIndexOf('/') + 1); | |
saveToDisk(url, filename); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script that downloads wallpapers from Windows page (http://windows.microsoft.com/pt-br/windows/wallpaper).
Paste this script in Console tab (F12) on your favorite browser.