Last active
December 17, 2015 09:09
-
-
Save moroya/5585431 to your computer and use it in GitHub Desktop.
image download
This file contains hidden or 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 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