-
Notifications
You must be signed in to change notification settings - Fork 6
/
passiveevents.user.js
45 lines (44 loc) · 1.13 KB
/
passiveevents.user.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
39
40
41
42
43
44
45
// ==UserScript==
// @name Passive events
// @namespace https://volafile.org
// @icon https://volafile.org/favicon.ico
// @author topkuk productions
// @include https://volafile.org/r/*
// @match https://volafile.org/r/*
// @version 1
// @description Because performance!
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
const unfucked = Object.freeze(new Set([
"resize",
"wheel",
"scroll",
"mouseenter",
"mousemove",
"mouseexit",
"mouseleave",
"mousewheel",
"touchmove",
]));
const addEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(type, fn, opts, ...args) {
if (unfucked.has(type)) {
if (typeof opts == "boolean") {
opts = {
capture: opts,
passive: true
};
}
else if (opts && typeof opts === "object") {
opts = Object.assign({}, opts, {passive: true});
}
else {
opts = {"passive": true};
}
}
return addEventListener.call(this, type, fn, opts, ...args);
}
})();