-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChangSpanColor.js
438 lines (334 loc) · 17.5 KB
/
ChangSpanColor.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
document.addEventListener('DOMContentLoaded', function() {
// 获取所有span元素
var spans = document.getElementsByTagName('span');
// 遍历每个span元素
for (var i = 0; i < spans.length; i++) {
if (spans[i].textContent.includes("//")) {
// 将span的颜色更改为绿色
spans[i].style.color = '#6a9955';
}
if (spans[i].textContent.trim() === "std") {
// 将span的颜色更改为绿色
spans[i].style.color = '#6a9955';
}
// 检查span的文本内容是否包含"string"
if (spans[i].textContent.trim() === "string") {
// 将span的颜色更改为绿色
spans[i].style.color = '#3ac9b0';
}
if (spans[i].textContent.startsWith('<') && spans[i].textContent.endsWith('>')) {
// 将span的颜色更改为绿色
spans[i].style.color = '#ce723c';
}
if (spans[i].textContent.trim() === "0"||spans[i].textContent.trim() === "1"||spans[i].textContent.trim() === "2"||spans[i].textContent.trim() === "3"||spans[i].textContent.trim() === "4"||spans[i].textContent.trim() === "5"||spans[i].textContent.trim() === "6"||spans[i].textContent.trim() === "7"||spans[i].textContent.trim() === "8"||spans[i].textContent.trim() === "9") {
// 将span的颜色更改为绿色
spans[i].style.color = '#b5ce9b';
}
if (spans[i].textContent.trim() === "stread()"||spans[i].textContent.trim() === "main()"||spans[i].textContent.trim() === "getchar()") {
// 将span的颜色更改为绿色
spans[i].style.color = '#cbcb33';
}
if (spans[i].textContent.trim() === "while"||spans[i].textContent.trim() === "for"||spans[i].textContent.trim() === "#include"||spans[i].textContent.trim() === "using"||spans[i].textContent.trim() === "return"||spans[i].textContent.trim() === "#define") {
// 将span的颜色更改为绿色
spans[i].style.color = '#c586a1';
}
if (spans[i].textContent.trim() === "char"||spans[i].textContent.trim() === "namespace"||spans[i].textContent.trim() === "int"||spans[i].textContent.trim() === "double"||spans[i].textContent.trim() === "bool"||spans[i].textContent.trim() === "LL"||spans[i].textContent.trim() === "long long") {
// 将span的颜色更改为绿色
spans[i].style.color = '#4a9cd6';
}
if (spans[i].textContent.includes('"')||spans[i].textContent.includes('\'')) {
// 将span的颜色更改为绿色
spans[i].style.color = '#ce916a';
}
if (spans[i].textContent.trim() === "s"||spans[i].textContent.trim() === "ch"||spans[i].textContent.trim() === "a"||spans[i].textContent.trim() === "b"||spans[i].textContent.trim() === "ans"||spans[i].textContent.trim() === "n"||spans[i].textContent.trim() === "i"||spans[i].textContent.trim() === "j"||spans[i].textContent.trim() === "v[10001][10001]"||spans[i].textContent.trim() === "f[10001]"||spans[i].textContent.trim() === "c[10001]"||spans[i].textContent.trim() === "f"||spans[i].textContent.trim() === "v[i][j]"||spans[i].textContent.trim() === "memset(f,0x3f,sizeof(f))") {
// 将span的颜色更改为绿色
spans[i].style.color = '#9cdcfe';
}
}
//------------------------------------------
// 获取所有的b标签
const aTags = document.getElementsByTagName('a');
// 遍历每一个b标签
for (let i = 0; i < aTags.length; i++) {
const aTag = aTags[i];
const textContent = aTag.textContent || aTag.innerText; // 兼容不同浏览器的文本内容获取
// 检查文本内容是否包含特定的字符串
if (textContent.includes('入门')) {
// 修改样式
aTag.style.backgroundColor = '#F20090';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('省选/NOI-')) {
// 修改样式
aTag.style.backgroundColor = '#9D3DCF';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('提高+/省选-')) {
// 修改样式
aTag.style.backgroundColor = '#3498DB';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('普及-')) {
// 修改样式
aTag.style.backgroundColor = '#F39C11';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('普及+/提高')) {
// 修改样式
aTag.style.backgroundColor = '#52C41A';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('普及/提高-')) {
// 修改样式
aTag.style.backgroundColor = '#FFC116';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('NOI/NOI+/CTSC')) {
// 修改样式
aTag.style.backgroundColor = '#0E1D69';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('Rated')) {
// 修改样式
aTag.style.backgroundColor = '#5EB95E';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
// 检查文本内容是否包含特定的字符串
if (textContent.includes('UnRated')) {
// 修改样式
aTag.style.backgroundColor = '#E74C3C';
aTag.style.borderRadius = '3px'; // 圆角边框
aTag.style.border = '1px solid black'; // 可选:添加边框以更清楚地看到效果
aTag.style.paddingLeft = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.paddingRight = '10px'; // 可选:增加一些内边距以使效果更明显
aTag.style.color = '#FFFFFF';
aTag.style.textDecoration = 'none';
aTag.style.borderStyle = 'none';
}
}
});
document.addEventListener('DOMContentLoaded', function() {
const container = document.getElementById('CF');
const links = container.getElementsByTagName('a');
// 定义一个函数来设置特殊链接的样式
function setSpecialLinkStyle(link) {
link.style.fontWeight = 'bold';
link.style.color = 'black';
link.style.textDecoration = 'none';
// 添加鼠标悬停事件监听器
link.addEventListener('mouseover', function() {
link.style.color = 'gray'; // 鼠标悬停时更改颜色
});
// 添加鼠标离开事件监听器以恢复原始颜色
link.addEventListener('mouseout', function() {
link.style.color = 'black'; // 鼠标离开时恢复颜色
});
}
// 遍历所有链接并应用样式
for (let i = 0; i < links.length; i++) {
const text = links[i].textContent || links[i].innerText;
const regex = /^[A-Z]\./;
if (regex.test(text.trim())) {
setSpecialLinkStyle(links[i]);
}
}
});
document.addEventListener('DOMContentLoaded', function() {
// 获取ID为CF的元素
const cfElement = document.getElementById('CF');
// 更改背景颜色
cfElement.style.backgroundColor = 'rgba(255,186, 2,0.8)';
});
document.addEventListener('DOMContentLoaded', function() {
// 获取ID为CF的元素
const cfElement = document.getElementById('CF');
// 创建一个新的img元素
const imgElement = document.createElement('img');
imgElement.style.maxHeight='80px';
imgElement.style.backgroundColor='white';
// 设置img元素的src属性为指定的URL
imgElement.src = 'https://upload-bbs.miyoushe.com/upload/2024/11/10/198629752/9d5d40b2b9cf67b7b9baadddd7e284a0_3255032010487932117.webp'; // 请替换为你的图片URL
// 添加点击事件监听器
imgElement.addEventListener('click', function() {
// 指定要跳转的URL
const targetUrl = 'https://codeforces.com/contests'; // 请替换为实际的目标URL
// 执行页面跳转
window.location.href = targetUrl;
});
// 可选:设置img元素的其他属性,如alt文本
imgElement.alt = 'Description of the image';
// 将img元素插入到CF元素的内容的最前面
cfElement.insertBefore(imgElement, cfElement.firstChild);
});
document.addEventListener('DOMContentLoaded', function() {
const container = document.getElementById('AT');
const links = container.getElementsByTagName('a');
container.style.color='white';
// 定义一个函数来设置特殊链接的样式
function setSpecialLinkStyle(link) {
link.style.fontWeight = 'bold';
link.style.color = 'white';
link.style.textDecoration = 'none';
// 添加鼠标悬停事件监听器
link.addEventListener('mouseover', function() {
link.style.color = 'gray'; // 鼠标悬停时更改颜色
});
// 添加鼠标离开事件监听器以恢复原始颜色
link.addEventListener('mouseout', function() {
link.style.color = 'white'; // 鼠标离开时恢复颜色
});
}
// 遍历所有链接并应用样式
for (let i = 0; i < links.length; i++) {
const text = links[i].textContent || links[i].innerText;
const regex = /^[A-Z]\ -/;
if (regex.test(text.trim())) {
setSpecialLinkStyle(links[i]);
}
}
});
document.addEventListener('DOMContentLoaded', function() {
// 获取ID为CF的元素
const cfElement = document.getElementById('AT');
// 更改背景颜色
cfElement.style.backgroundColor = 'rgba( 45, 51, 59,0.8)';
});
document.addEventListener('DOMContentLoaded', function() {
// 获取ID为CF的元素
const cfElement = document.getElementById('AT');
// 创建一个新的img元素
const imgElement = document.createElement('img');
imgElement.style.maxHeight='80px';
imgElement.style.backgroundColor='black';
// 设置img元素的src属性为指定的URL
imgElement.src = 'https://upload-bbs.miyoushe.com/upload/2024/11/10/198629752/0e376758c2a79d84a388734053349d88_8323781477114625186.png'; // 请替换为你的图片URL
// 添加点击事件监听器
imgElement.addEventListener('click', function() {
// 指定要跳转的URL
const targetUrl = 'https://atcoder.jp/contests/'; // 请替换为实际的目标URL
// 执行页面跳转
window.location.href = targetUrl;
});
// 可选:设置img元素的其他属性,如alt文本
imgElement.alt = 'Description of the image';
// 将img元素插入到CF元素的内容的最前面
cfElement.insertBefore(imgElement, cfElement.firstChild);
});
document.addEventListener('DOMContentLoaded', function() {
// 获取ID为CF的元素
const cfElement = document.getElementById('AT');
const childElements = cfElement.getElementsByTagName('a');
for (let i = 0; i < childElements.length; i++) {
childElements[i].style.color = 'white';
childElements[i].style.textDecoration='none';
}
cfElement.style.color = 'white';
});
document.addEventListener('DOMContentLoaded', function() {
const container = document.getElementById('LG');
const links = container.getElementsByTagName('a');
// 定义一个函数来设置特殊链接的样式
function setSpecialLinkStyle(link) {
link.style.fontWeight = 'bold';
link.style.color = 'black';
link.style.textDecoration = 'none';
// 添加鼠标悬停事件监听器
link.addEventListener('mouseover', function() {
link.style.color = 'gray'; // 鼠标悬停时更改颜色
});
// 添加鼠标离开事件监听器以恢复原始颜色
link.addEventListener('mouseout', function() {
link.style.color = 'black'; // 鼠标离开时恢复颜色
});
}
// 遍历所有链接并应用样式
for (let i = 0; i < links.length; i++) {
const text = links[i].textContent || links[i].innerText;
const regex = /^[A-Z]\./;
if (regex.test(text.trim())) {
setSpecialLinkStyle(links[i]);
}
}
});
document.addEventListener('DOMContentLoaded', function() {
// 获取ID为CF的元素
const cfElement = document.getElementById('LG');
// 更改背景颜色
cfElement.style.backgroundColor = 'rgba(231,245,231,0.8)';
});
document.addEventListener('DOMContentLoaded', function() {
// 获取ID为CF的元素
const cfElement = document.getElementById('LG');
// 创建一个新的img元素
const imgElement = document.createElement('img');
imgElement.style.maxHeight='80px';
imgElement.style.backgroundColor='white';
// 设置img元素的src属性为指定的URL
imgElement.src = 'https://upload-bbs.miyoushe.com/upload/2024/11/10/198629752/35e6d0796eab39c4bf304d03e6d332c0_3893909472695035573.png'; // 请替换为你的图片URL
// 添加点击事件监听器
imgElement.addEventListener('click', function() {
// 指定要跳转的URL
const targetUrl = 'https://www.luogu.com.cn/'; // 请替换为实际的目标URL
// 执行页面跳转
window.location.href = targetUrl;
});
// 可选:设置img元素的其他属性,如alt文本
imgElement.alt = 'Description of the image';
// 将img元素插入到CF元素的内容的最前面
cfElement.insertBefore(imgElement, cfElement.firstChild);
});