-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentScriptReddit.js
More file actions
52 lines (45 loc) · 1.06 KB
/
contentScriptReddit.js
File metadata and controls
52 lines (45 loc) · 1.06 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
console.log("KeyTabber running");
var aElemets;
var i = -1;
function eventFire(el, etype) {
if (el.fireEvent) {
el.fireEvent("on" + etype);
} else {
var evObj = document.createEvent("Events");
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
document.addEventListener("keydown", logKey);
function logKey(e) {
if (e.which == 9) {
e.preventDefault();
aElemets = document.querySelectorAll(".SQnoC3ObvgnGjWt90zD9Z");
removeClass();
if (e.shiftKey) {
i--;
if (i < 0) {
i = 0;
}
} else {
i++;
if (i > aElemets.length - 1) {
i = aElemets.length - 1;
}
}
aElemets[i].focus();
aElemets[i].classList.add("boxshadow");
}
console.log(e.which);
if (e.which == 38 || e.which == 40) {
console.log("firing");
//eventFire(document.querySelector(".yk4f6w-0.cCMdtd"), "click");
console.log(document.querySelector(".yk4f6w-0.cCMdtd"));
//.focus();
}
}
function removeClass() {
try {
aElemets[i].classList.remove("boxshadow");
} catch (e) {}
}