Skip to content

Instantly share code, notes, and snippets.

@moroya
Last active December 17, 2015 09:09
Show Gist options
  • Save moroya/5585431 to your computer and use it in GitHub Desktop.
Save moroya/5585431 to your computer and use it in GitHub Desktop.
image download
var imgs = document.querySelectorAll('a[href*="jpg"], a[href*="gif"], a[href*="png"]');
for(var i=0;i<imgs.length;i++) {
dispatchMouseEvents({ type:'click', altKey:true, target:imgs[i], button:0 });
}
function dispatchMouseEvents(opt) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent(opt.type, opt.canBubble||true, opt.cancelable||true, opt.view||window,
opt.detail||0, opt.screenX||0, opt.screenY||0, opt.clientX||0, opt.clientY||0,
opt.ctrlKey||false, opt.altKey||false, opt.shiftKey||false, opt.metaKey||false,
opt.button||0, opt.relatedTarget||null);
opt.target.dispatchEvent(evt);
return evt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment