-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasy-image-dw
30 lines (28 loc) · 1.02 KB
/
easy-image-dw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ==UserScript==
// @name Easy Image Downloader
// @namespace http://yourwebsite.com
// @version 1.0
// @description Opens image in new tab when Alt key + Left click is used, prompts to save image when Alt + Shift + Left click is pressed
// @author ayusht9
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('click', function(event) {
if (event.altKey && event.button === 0 && event.target.tagName === 'IMG') {
if (event.shiftKey) {
// Save Image Prompt (Alt + Shift + Left Click)
event.preventDefault();
var imageUrl = event.target.src;
var link = document.createElement('a');
link.href = imageUrl;
link.download = '';
link.click();
} else {
// Open Image in New Tab (Alt + Left Click)
window.open(event.target.src, '_blank');
}
}
});
})();