Skip to content

Instantly share code, notes, and snippets.

@andrzj
Last active June 5, 2016 17:22
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 andrzj/2018b178eda4444c604f to your computer and use it in GitHub Desktop.
Save andrzj/2018b178eda4444c604f to your computer and use it in GitHub Desktop.
Windows wallpaper download script
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);
}
@andrzj
Copy link
Author

andrzj commented Dec 27, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment