forked from Inve1951/BetterDiscordStuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autocompleteHoverFix.plugin.js
70 lines (61 loc) · 1.74 KB
/
autocompleteHoverFix.plugin.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//META{"name":"autocompleteHoverFix"}*//;
var autocompleteHoverFix;
autocompleteHoverFix = class autocompleteHoverFix {
getName() {
return "Autocomplete-Hover-Fix";
}
getDescription() {
return "If the autocompletion menu selects entries without your doing then this is for you.";
}
getAuthor() {
return "square";
}
getVersion() {
return "1.0.2";
}
start() {}
stop() {}
load() {}
observer(m) {
var e, node, ref;
try {
({
addedNodes: [node]
} = m);
} catch (error) {
e = error;
return;
}
if ("function" === typeof (node != null ? (ref = node.className) != null ? ref.indexOf : void 0 : void 0) && ((-1 !== node.className.indexOf("autocomplete-")) || -1 !== node.className.indexOf("popout-"))) {
e = document.createElement("div");
e.style = "position: absolute;\nwidth: 100%;\nheight: 100%;\ntop: 0; left: 0;";
e.onmousemove = function({clientX, clientY}) {
if ((this.x != null) && (this.y != null) && (this.x !== clientX || this.y !== clientY)) {
this.remove();
e = document.elementFromPoint(clientX, clientY);
while (true) {
if (e === document.body) {
return;
}
if (-1 !== e.className.indexOf("selectable-")) {
e = e.parentNode;
break;
} else if (-1 !== e.className.indexOf("search-option")) {
break;
}
e = e.parentNode;
}
e.dispatchEvent(new MouseEvent("mouseover", {
clientX,
clientY,
bubbles: true
}));
return;
}
this.x = clientX;
this.y = clientY;
};
node.appendChild(e);
}
}
};