-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage-opener.js
38 lines (32 loc) · 1020 Bytes
/
image-opener.js
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
31
32
33
34
35
36
37
38
// ==UserScript==
// @name Image Opener
// @namespace http://tampermonkey.net/
// @version 1.1.1
// @description Opens a image with a hotkey and a click
// @author LeonAM
// @match *://*/*
// @require file://<PATH>/image-opener.js
// @grant GM_info
// @grant GM_openInTab
// ==/UserScript==
(function () {
'use strict';
console.log(`Running UserScript "${GM_info.script.name}"`);
document.addEventListener("click", e => {
if (e.target.tagName !== "IMG") return;
var ctrl = e.ctrlKey;
var alt = e.altKey;
var shift = e.shiftKey;
// CTRL + ALT
if (ctrl && alt && !shift && e.which === 1) {
e.preventDefault();
e.stopPropagation();
GM_openInTab(e.target.src, { active: false });
}
// CTRL + SHIFT
if (ctrl && !alt && shift && e.which === 1) {
e.stopPropagation();
window.open(e.target.src, "_self");
}
});
})();