-
Notifications
You must be signed in to change notification settings - Fork 11
/
try2cn.js
173 lines (124 loc) · 4.5 KB
/
try2cn.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
论坛
*/
function isNull(data) {
return (data == "" || data == undefined || data == null) ? true: false;
}
function RepItemSkillTree(link, linkCN) {
var skill = document.getElementsByClassName('characterPassiveSkillTree');
if (typeof(skill) == 'undefined') {
return;
}
var iframe = skill[0].getElementsByTagName('iframe')[0];
if (typeof(iframe) == 'undefined') {
return;
}
var tmp_linkCN = linkCN;
var itemBoxContent = iframe.contentWindow.document.getElementsByClassName('itemBoxContent');
for (var i = 0; i < itemBoxContent.length; i++) {
var group = link.exec(itemBoxContent[i].innerHTML);
if (isNull(group) != true) {
linkCN = tmp_linkCN;
for (var j = 1; j < group.length; j = j + 2) {
if (typeof(group[j]) != 'undefined') {
linkCN = linkCN.replace('#', group[j]);
}
}
itemBoxContent[i].innerHTML = itemBoxContent[i].innerHTML.replace(group[0], linkCN);
group = [];
}
}
linkCN = '';
}
function RepItem(link, linkCN) {
var tmp_linkCN = linkCN;
var itemBoxContent = document.getElementsByClassName('itemBoxContent');
for (var i = 0; i < itemBoxContent.length; i++) {
var group = link.exec(itemBoxContent[i].innerHTML);
if (isNull(group) != true) {
linkCN = tmp_linkCN;
for (var j = 1; j < group.length; j = j + 2) {
if (typeof(group[j]) != 'undefined') {
linkCN = linkCN.replace('#', group[j]);
}
}
itemBoxContent[i].innerHTML = itemBoxContent[i].innerHTML.replace(group[0], linkCN);
group = [];
}
}
linkCN = '';
}
if (document.location.href.indexOf('poe.ninja/') != -1
&& document.location.href.indexOf('/builds') != -1
) {
// ninjaFun;
} else { //官网
for (var trynum = 0; trynum < 3; trynum++) {
document.title = '第' + (trynum + 1) + '遍正在处理';
for (var i = 0; i < modsjson.length; i++) {
link = modsjson[i].en;
linkCN = modsjson[i].cn;
//遍历珠宝in论坛 优先加载处理后的珠宝词缀进行
if (document.location.href.indexOf('account/view-profile') == -1) {
//论坛用普通遍历
RepItem(link, linkCN);
} else {
RepItem(link, linkCN);
//否则要iframe。 处理后的珠宝词缀
RepItemSkillTree(link, linkCN);
}
}
for (var i = 0; i < itemjson.length; i++) {
link = itemjson[i].en;
linkCN = itemjson[i].cn;
RepItem(link, linkCN);
}
for (var i = 0; i < ExplicitModjson.length; i++) {
link = ExplicitModjson[i].en;
linkCN = ExplicitModjson[i].cn;
if (document.location.href.indexOf('account/view-profile') == -1) {
RepItem(link, linkCN);
//当前词缀进行珠宝 默认就是了
} else {
//否则要iframe
RepItem(link, linkCN);
RepItemSkillTree(link, linkCN);
}
}
for (var i = 0; i < gemJson.length; i++) {
link = gemJson[i].en;
linkCN = gemJson[i].cn;
RepItem(link, linkCN);
}
for (var i = 0; i < uniqueNameJson.length; i++) {
link = uniqueNameJson[i].en;
linkCN = uniqueNameJson[i].cn;
RepItem(link, linkCN);
}
for (var i = 0; i < baseItemJson.length; i++) {
link = baseItemJson[i].en;
linkCN = baseItemJson[i].cn;
RepItem(link, linkCN);
}
if (document.location.href.indexOf('account/view-profile') != -1) {
for (var i = 0; i < baseJewelJson.length; i++) {
link = baseJewelJson[i].en;
linkCN = baseJewelJson[i].cn;
RepItemSkillTree(link, linkCN);
}
} else {
for (var i = 0; i < baseJewelJson.length; i++) {
link = baseJewelJson[i].en;
linkCN = baseJewelJson[i].cn;
RepItem(link, linkCN);
}
}
for (var i = 0; i < baseItemTypeJson.length; i++) {
link = baseItemTypeJson[i].en;
linkCN = baseItemTypeJson[i].cn;
RepItem(link, linkCN);
}
}
document.title = '处理完成';
alert('完成');
}