-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentScriptYoutube.js
More file actions
70 lines (62 loc) · 1.57 KB
/
contentScriptYoutube.js
File metadata and controls
70 lines (62 loc) · 1.57 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
console.log("KeyTabber running");
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);
}
}
var ytd_browse;
//loading direct to watch?v=... don't have ytd-browse
if (document.getElementById("show-more-button")) {
eventFire(document.getElementById("show-more-button"), "click");
}
var aElemets;
var i = -1;
document.addEventListener("yt-navigate-finish", function(event) {
if (document.getElementById("show-more-button")) {
eventFire(document.getElementById("show-more-button"), "click");
}
removeClass();
i = -1;
});
function parseLocation() {}
document.addEventListener("keydown", logKey);
function logKey(e) {
if (e.which == 9) {
e.preventDefault();
aElemets = document
.querySelector("[role='main']")
.querySelectorAll("[id='video-title']");
removeClass();
if (e.shiftKey) {
i--;
if (i < 0) {
i = 0;
}
} else {
i++;
if (i > aElemets.length - 1) {
i = aElemets.length - 1;
}
}
if (aElemets[i].nodeName == "A") {
aElemets[i].focus();
aElemets[i].classList.add("boxshadow");
} else {
aElemets[i].closest("a").focus();
aElemets[i].closest("a").classList.add("boxshadow");
}
}
}
function removeClass() {
try {
if (aElemets[i].nodeName == "A") {
aElemets[i].classList.remove("boxshadow");
} else {
aElemets[i].closest("a").classList.remove("boxshadow");
}
} catch (e) {}
}