Skip to content

Commit 050b571

Browse files
committed
优化 代码
1 parent bab3f93 commit 050b571

7 files changed

Lines changed: 37 additions & 43 deletions

3dm-Beautification.user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// @homepageURL https://github.com/XIU2/UserScript
1313
// ==/UserScript==
1414

15-
'use strict';
1615
(function() {
16+
'use strict';
1717
let style_Add = document.createElement('style');
1818
style_Add.innerHTML = `
1919
[url=home.php?mod=space&uid=945662]@media[/url] (min-width:1366px) {
@@ -98,6 +98,6 @@ textarea#fastpostmessage {
9898
document.head.appendChild(style_Add);
9999
clearInterval(timer);
100100
}
101-
}, 1);
101+
});
102102
}
103103
})();

3dm-Enhanced.user.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
// @homepageURL https://github.com/XIU2/UserScript
2020
// ==/UserScript==
2121

22-
'use strict';
2322
(function() {
23+
'use strict';
2424
var menu_ALL = [
2525
['menu_autoReply', '自动回复', '自动回复', true],
2626
['menu_cleanTopPost', '清理置顶帖子', '清理置顶帖子', true],
@@ -186,7 +186,7 @@
186186
let checklogin = document.querySelectorAll('.wp.h_menu p a');
187187
if (checklogin){
188188
for (let value of checklogin) {
189-
if (value.innerHTML == "退出"){
189+
if (value.textContent == '退出'){
190190
loginStatus = true;
191191
}
192192
}
@@ -220,10 +220,10 @@
220220

221221
// 写入自动回复内容
222222
function writeReply(){
223-
let textarea = document.getElementById("fastpostmessage");
223+
let textarea = document.getElementById('fastpostmessage');
224224
if (textarea){
225225
textarea.value = textarea.value + replyList[Math.floor((Math.random()*replyList.length))] + replyList[Math.floor((Math.random()*replyList.length))];
226-
let fastpostsubmit = document.getElementById("fastpostsubmit");
226+
let fastpostsubmit = document.getElementById('fastpostsubmit');
227227
if (fastpostsubmit){
228228
fastpostsubmit.click();
229229
}
@@ -233,7 +233,7 @@
233233

234234
// 清理置顶帖子
235235
function cleanTopPost(){
236-
let showhide = document.querySelectorAll("a.showhide.y");
236+
let showhide = document.querySelectorAll('a.showhide.y');
237237
if (showhide.length > 0){
238238
showhide.forEach(el=>el.click());
239239
}
@@ -242,9 +242,7 @@
242242

243243
// 隐藏帖子内的 [下一页] 按钮
244244
function hidePgbtn() {
245-
let style_hidePgbtn = document.createElement('style');
246-
style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`;
247-
document.head.appendChild(style_hidePgbtn);
245+
document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
248246
}
249247

250248

@@ -258,7 +256,7 @@
258256
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
259257
if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了
260258
let autopbn = document.querySelector('#autopbn');
261-
if (autopbn && autopbn.innerText == "下一页 »"){ // 如果已经在加载中了,就忽略
259+
if (autopbn && autopbn.textContent == '下一页 »'){ // 如果已经在加载中了,就忽略
262260
autopbn.click();
263261
}
264262
}else{

52pojie-Beautification.user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// @homepageURL https://github.com/XIU2/UserScript
1919
// ==/UserScript==
2020

21-
'use strict';
2221
(function() {
22+
'use strict';
2323
var menu_ALL = [
2424
['menu_rule', '隐藏版规', '隐藏版规', false]
2525
], menu_ID = [];

52pojie-Enhanced.user.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
// @homepageURL https://github.com/XIU2/UserScript
2020
// ==/UserScript==
2121

22-
'use strict';
2322
(function() {
23+
'use strict';
2424
var menu_ALL = [
2525
['menu_autoClockIn', '自动签到', '自动签到', true],
2626
['menu_pageLoading', '自动无缝翻页', '自动无缝翻页', true],
@@ -191,14 +191,14 @@
191191
if (qiandao) {
192192
GM_xmlhttpRequest({
193193
url: qiandao.href,
194-
method: "GET",
194+
method: 'GET',
195195
timeout: 5000,
196196
onload: function (response) {
197197
let html = ShowPager.createDocumentByString(response.responseText);
198198
html = html.querySelector('#messagetext p')
199-
if (html && html.innerText.indexOf('任务已完成') > -1 || html && html.innerText.indexOf('已申请过此任务') > -1) {
200-
qiandao.querySelector('.qq_bind').setAttribute('src','https://www.52pojie.cn/static/image/common/wbs.png') // 修改 [打卡签到] 图标为 [签到完毕]
201-
qiandao.href = "#" // 修改 URL 为 #
199+
if (html && html.textContent.indexOf('任务已完成') > -1 || html && html.textContent.indexOf('已申请过此任务') > -1) {
200+
qiandao.querySelector('.qq_bind').src = 'https://www.52pojie.cn/static/image/common/wbs.png'; // 修改 [打卡签到] 图标为 [签到完毕] 图标
201+
qiandao.href = 'javascript:void(0);'
202202
} else {
203203
GM_notification({text: '自动签到失败!请联系作者解决!', title: '吾爱破解论坛增强', timeout: 3000});
204204
}
@@ -229,9 +229,7 @@
229229

230230
// 隐藏帖子内的 [下一页] 按钮
231231
function hidePgbtn() {
232-
let style_hidePgbtn = document.createElement('style');
233-
style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`;
234-
document.head.appendChild(style_hidePgbtn);
232+
document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
235233
}
236234

237235

@@ -248,7 +246,7 @@
248246
ShowPager.loadMorePage();
249247
} else {
250248
let autopbn = document.querySelector(curSite.pager.nextLink);
251-
if (autopbn && autopbn.innerText == curSite.pager.nextText) { // 如果正在加载,就不再点击
249+
if (autopbn && autopbn.textContent == curSite.pager.nextText) { // 如果正在加载,就不再点击
252250
autopbn.click();
253251
}
254252
}

Hostloc-Enhanced.user.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
listItem.forEach(function(item){ // 遍历所有帖子
279279
menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单
280280
let itemName = item.querySelector(list2); // 寻找用户名
281-
if (itemName && itemName.innerText === item1) {
281+
if (itemName && itemName.textContent === item1) {
282282
console.log(`屏蔽用户:${item1}`);
283283
item.remove(); // 删除帖子
284284
}
@@ -294,7 +294,7 @@
294294
listItem.forEach(function(item){ // 遍历所有回复
295295
menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单
296296
let itemName = item.querySelector('a.xi2'); // 寻找用户名
297-
if (itemName && itemName.innerText === item1) {
297+
if (itemName && itemName.textContent === item1) {
298298
console.log(`屏蔽用户:${item1}`);
299299
item.remove(); // 删除回复
300300
}
@@ -331,8 +331,8 @@
331331
listItem.forEach(function(item){ // 遍历所有帖子标题
332332
menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词
333333
let itemName = item.querySelector('a.s.xst'); // 寻找帖子标题
334-
if (itemName && itemName.innerText.indexOf(item1) > -1) {
335-
console.log(`屏蔽关键词:[${item1}]`, `,帖子标题:[${itemName.innerText}]`);
334+
if (itemName && itemName.textContent.indexOf(item1) > -1) {
335+
console.log(`屏蔽关键词:[${item1}]`, `,帖子标题:[${itemName.textContent}]`);
336336
item.remove(); // 删除帖子
337337
}
338338
})
@@ -343,7 +343,7 @@
343343
// 监听插入事件(有新的回复主题,点击查看)
344344
function blockDOMNodeInserted() {
345345
let block = e => {
346-
if (e.target.innerText && e.target.innerText.indexOf('newthread') > -1) {
346+
if (e.target.textContent && e.target.textContent.indexOf('newthread') > -1) {
347347
setTimeout(function () {
348348
blockUsers('forum'); // 屏蔽用户(黑名单)
349349
blockKeywords(); // 屏蔽关键词(帖子标题)
@@ -426,7 +426,7 @@
426426

427427
function replyCustom_3() {
428428
let postsubmit = document.getElementById('postsubmit');
429-
if (postsubmit && postsubmit.innerText === '\n参与/回复主题\n' || postsubmit && postsubmit.innerText === '\n发表帖子\n') {
429+
if (postsubmit && postsubmit.textContent === '\n参与/回复主题\n' || postsubmit && postsubmit.textContent === '\n发表帖子\n') {
430430
postsubmit.onclick = function(){
431431
if (GM_getValue('menu_customLittleTail')) document.getElementById('e_textarea').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');
432432
}
@@ -438,7 +438,7 @@
438438
// 监听插入事件(回帖间隔)
439439
/*function replyIntervalDOMNodeInserted() {
440440
let replyInterval = e => {
441-
if (e.target.innerHTML && e.target.innerText.indexOf('发表回复 金钱+1') > -1) {
441+
if (e.target.innerHTML && e.target.textContent.indexOf('发表回复 金钱+1') > -1) {
442442
setTimeout(function () {GM_notification({text: '过去 60 秒了,可以回帖了~', timeout: 3500});}, 60000)
443443
}
444444
}
@@ -459,9 +459,7 @@
459459

460460
// 隐藏帖子内的 [下一页] 按钮
461461
function hidePgbtn() {
462-
let style_hidePgbtn = document.createElement('style');
463-
style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`;
464-
document.head.appendChild(style_hidePgbtn);
462+
document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
465463
}
466464

467465

@@ -496,10 +494,10 @@
496494
// 显示在线状态
497495
function onlineStatus() {
498496
document.querySelectorAll('[id^="favatar"]').forEach(function(item){ // 遍历所有帖子
499-
let icon = (item.querySelector('[id^="userinfo"] > .i.y em').innerText === '当前在线') ? '🌝' : '🌚';
497+
let icon = (item.querySelector('[id^="userinfo"] > .i.y em').textContent === '当前在线') ? '🌝' : '🌚';
500498
let divStatus = document.createElement('div');
501499
divStatus.style = 'position: absolute;margin: -8px 0 0 8px;padding: 0 1px 1.2px;background-color: #ffffff;border-radius: 50%;';
502-
divStatus.innerText = icon;
500+
divStatus.textContent = icon;
503501
let mochu = item.querySelector('.avatar');
504502
mochu.parentNode.insertBefore(divStatus,mochu);
505503
})
@@ -511,7 +509,7 @@
511509
if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1){
512510
let tbody = document.querySelectorAll('tbody[id^="normalthread_"] .xw1');
513511
Array.from(tbody).forEach(function (_this) {
514-
if (_this.innerText === '255') {
512+
if (_this.textContent === '255') {
515513
_this.parentNode.parentNode.parentNode.remove();
516514
}
517515
})
@@ -529,10 +527,10 @@
529527
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + 999) {
530528
if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了
531529
let autopbn = document.querySelector('#autopbn');
532-
if (autopbn && autopbn.innerText === "下一页 »"){ // 如果已经在加载中了,就忽略
530+
if (autopbn && autopbn.textContent === "下一页 »"){ // 如果已经在加载中了,就忽略
533531
autopbn.click();
534532
let timer = setInterval(function(){ // 在下一页加载完成后
535-
if (document.querySelector('#autopbn').innerText === "下一页 »") {
533+
if (document.querySelector('#autopbn').textContent === "下一页 »") {
536534
if (menu_value('menu_delate255')) delate255(); // 隐藏 255 权限帖子
537535
if (menu_value('menu_blockUsers')) blockUsers('forum'); // 屏蔽用户(黑名单)
538536
if (menu_value('menu_blockKeywords')) blockKeywords(); // 屏蔽关键词(帖子标题)

V2ex-Enhanced.user.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// @homepageURL https://github.com/XIU2/UserScript
2121
// ==/UserScript==
2222

23-
'use strict';
2423
(function() {
24+
'use strict';
2525
var menu_ALL = [
2626
['menu_autoClockIn', '自动签到', '自动签到', true],
2727
['menu_linksToImgs', '链接转图片', '链接转图片', true],
@@ -245,22 +245,22 @@
245245
let url = (location.origin + "/mission/daily/redeem?" + RegExp("once\\=(\\d+)").exec(document.querySelector('div#Top .tools').innerHTML)[0]);
246246
GM_xmlhttpRequest({
247247
url: url,
248-
method: "GET",
248+
method: 'GET',
249249
timeout: 5000,
250250
onload: function (response) {
251251
let html = ShowPager.createDocumentByString(response.responseText);
252252
if (html.querySelector('li.fa.fa-ok-sign')) {
253-
html = html.getElementById('Main').innerText.match(/ (\d+?) /)[0];
253+
html = html.getElementById('Main').textContent.match(/ (\d+?) /)[0];
254254
GM_setValue('menu_clockInTime', timeNow); // 写入签到时间以供后续比较
255255
console.info('[V2EX 增强] 自动签到完成!')
256256
if (qiandao) {
257-
qiandao.innerText = `自动签到完成!${html}`;
258-
qiandao.href = '#';
257+
qiandao.textContent = `自动签到完成!${html}`;
258+
qiandao.href = 'javascript:void(0);';
259259
}
260260
} else {
261261
GM_notification({text: '自动签到失败!请联系作者解决!', timeout: 4000, onclick() {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/424246/feedback', {active: true,insert: true,setParent: true});}});
262262
console.warn('[V2EX 增强] 自动签到失败!请联系作者解决!')
263-
if (qiandao) qiandao.innerText = '自动签到失败!请尝试手动签到!';
263+
if (qiandao) qiandao.textContent = '自动签到失败!请尝试手动签到!';
264264
}
265265
}
266266
});

Zhiyoo-Enhanced.user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// @homepageURL https://github.com/XIU2/UserScript
2121
// ==/UserScript==
2222

23-
'use strict';
2423
(function() {
24+
'use strict';
2525
var menu_ALL = [
2626
['menu_autoReply', '自动回复', '自动回复', true],
2727
['menu_pageLoading', '自动无缝翻页', '自动无缝翻页', true],

0 commit comments

Comments
 (0)