-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserscript.js
More file actions
37 lines (34 loc) · 1.23 KB
/
userscript.js
File metadata and controls
37 lines (34 loc) · 1.23 KB
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
// ==UserScript==
// @name GeoFS Camera Reset
// @version 1.1
// @description Reset GeoFS camera when middle mouse button is double-clicked
// @author krunchiekrunch
// @match https://www.geo-fs.com/geofs.php?v=*
// @match https://*.geo-fs.com/geofs.php*
// @icon https://www.google.com/s2/favicons?sz=64&domain=geo-fs.com
// @grant none
// @license CC BY-NC-SA 4.0
// ==/UserScript==
(function() {
'use strict';
let clickCount = 0;
const clickDelay = 300; // maximum time (ms) between clicks to be considered a double click
let clickTimer;
document.addEventListener('mousedown', function(event) {
if (event.button === 1) {
clickCount++;
if (clickCount === 1) {
clickTimer = setTimeout(function() {
clickCount = 0;
}, clickDelay);
} else if (clickCount === 2) {
clearTimeout(clickTimer);
clickCount = 0;
// reset camera
if (typeof geofs !== 'undefined' && geofs.camera && typeof geofs.camera.reset === 'function') {
geofs.camera.reset();
}
}
}
}, false);
})();