-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtchighlight.js
More file actions
140 lines (137 loc) · 3.96 KB
/
tchighlight.js
File metadata and controls
140 lines (137 loc) · 3.96 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// ==UserScript==
// @include http://boards.endoftheinter.net/showmessages*
// @include https://boards.endoftheinter.net/showmessages*
// ==/UserScript==
/*chrome.extension.sendRequest({need: "chromeLL_tchighlight"}, function(response) {
if(response.data == "true"){
chrome.extension.sendRequest({need: "chromeLL_tchighlightcolor"}, function(response) {
if(window.location.href.indexOf('board=444') != -1){
ha(response.data);
}
else{
tchl(response.data);
}
});
}
});*/
alert(localStorage['chromeLL_currenttc']);
tchl('#fff');
function tchl(hlcolor){
if(localStorage['chromeLL_currenttc'] == undefined){
localStorage['chromeLL_currenttc'] = 'test:234341;fsdef:34234';
}
var ls = localStorage['chromeLL_currenttc'];
var g = document.getElementsByTagName('div').item(6).getElementsByTagName('a').item(0).innerHTML;
var o = document.getElementsByClassName('message-top').item(0).getElementsByTagName('a').item(0).innerHTML;
var j = 0;
var w = "" + window.location;
var tcs = new Array();
var tnum = new Array();
var topicnum = getTopic(w);
var index = -1;
if(ls.indexOf(":") == -1){
ls = 'test:234341;fsdef:34234';
}
var ovr = ls.split('$COL$')[0];
var tlists = ovr.split(';');
for(var q = 0; tlists[q]; q++){
tcs[q] = tlists[q].split(':')[0].toLowerCase();
tnum[q] = tlists[q].split(':')[1].toLowerCase();
}
if(w.indexOf("page") == -1 || w.indexOf("page=1") != -1){
if(ls.indexOf(getTopic(w)) == -1){
tcs[tcs.length] = o.toLowerCase();
tnum[tnum.length] = getTopic(w);
index = tcs.length - 1;
}
}
if(index == -1){
for(var i = 0; i < tcs.length; i++){
if(tnum[i] == getTopic(w)){
index = i;
}
}
}
while(document.getElementsByClassName('message-top').item(j)){
var s = document.getElementsByClassName('message-top').item(j);
if(s.getElementsByTagName('a').item(0).innerHTML.toLowerCase() == tcs[index]){
s.getElementsByTagName('a').item(0).style.color = hlcolor;
}
j = j + 1;
}
save(tcs, tnum, hlcolor);
}
function getTopic(pw){
return pw.substring(pw.indexOf("topic") + 6, pw.indexOf("topic") + 13);
}
function save(tc, tl, hlc){
var def = '';
if(tc.length > 10){
for(var i = tc.length - 10; i <= 10; i++){
def += tc[i] + ":" + tl[i] + ";";
}
//console.log('cache rebuilt');
}
else{
for(var i = 0; i < tc.length; i++){
def += tc[i] + ":" + tl[i] + ";";
}
}
localStorage['chromeLL_currenttc'] = def + "$COL$" + hlc;
}
function ha(hlc){
console.log('TC highlighting has been disabled on HA');
}
document.addEventListener('DOMNodeInserted', tchl_update, false);
function tchl_update(e){
var ls = localStorage['chromeLL_currenttc'];
var hlcolor = ls.split('$COL$')[1];
//the easy way out
//tchl(hlcolor);
try{e.target.getElementsByClassName("message-top").item(0);}
catch (e){
return 0;
}
var ls = localStorage['chromeLL_currenttc'];
var ovr = ls.split('$COL$')[0];
var hlcolor = ls.split('$COL$')[1];
var tlists = ovr.split(';');
var tcs = Array();
var tnum = Array();
var get=getUrlVars(window.location.href);
for(var q = 0; tlists[q]; q++){
tcs[q] = tlists[q].split(':')[0].toLowerCase();
tnum[q] = tlists[q].split(':')[1].toLowerCase();
}
var updates = 0;
if(e.target.getElementsByClassName("message-top").item(0) != null){
var es=e.target.getElementsByClassName("message-top");
var s = es.item(0);
//console.log(tnum, get['topic']);
//console.log(s.getElementsByTagName('a').item(0).innerHTML);
for(var index = 0; tnum[index]; index++){
if(tnum[index] == get['topic']){
if(s.getElementsByTagName('a').item(0).innerHTML.toLowerCase() == tcs[index]){
s.getElementsByTagName('a').item(0).style.color = hlcolor;
}
}
}
}
}
function getUrlVars(urlz)
{
//thanks for the function citizenray
var vars = [], hash;
var hashes = urlz.slice(urlz.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
if (hash[1]!=null && hash[1].indexOf("#")>=0)
{
vars[hash[0]]=hash[1].slice(0,hash[1].indexOf("#"));
}
}
return vars;
}