Skip to content

Commit a230e44

Browse files
committed
优化 代码
1 parent d472df0 commit a230e44

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

Hostloc-Enhanced.user.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 全球主机交流论坛增强
3-
// @version 1.3.4
3+
// @version 1.3.5
44
// @author X.I.U
55
// @description 自动签到(访问空间 +22 积分)、屏蔽用户(黑名单)、屏蔽关键词(帖子标题)、回帖小尾巴、自动无缝翻页、快捷回到顶部(右键点击两侧空白处)、收起预览帖子(左键点击两侧空白处)、预览帖子快速回复带签名、显示是否在线、显示帖子内隐藏回复、屏蔽阅读权限 255 帖子
66
// @match *://hostloc.com/*
@@ -29,7 +29,7 @@
2929
['menu_customBlockUsers', '自定义屏蔽用户', '自定义屏蔽用户', []],
3030
['menu_blockKeywords', '屏蔽关键词(帖子标题)', '屏蔽关键词(帖子标题)', false],
3131
['menu_customBlockKeywords', '自定义屏蔽关键词', '自定义屏蔽关键词', []],
32-
['menu_customLittleTail', '自定义小尾巴内容', '自定义小尾巴内容', []],
32+
['menu_customLittleTail', '自定义小尾巴内容', '自定义小尾巴内容', ''],
3333
['menu_pageLoading', '自动无缝翻页(总开关)', '自动无缝翻页', true],
3434
['menu_thread_pageLoading', '帖子内自动翻页', '帖子内自动翻页', true],
3535
['menu_backToTop', '快捷回到顶部(右键点击两侧空白处)', '快捷回到顶部', true],
@@ -59,6 +59,7 @@
5959
} else if (menu_ALL[i][0] === 'menu_customBlockKeywords') {
6060
menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){customBlockKeywords()});
6161
} else if (menu_ALL[i][0] === 'menu_customLittleTail') {
62+
if (menu_value(menu_ALL[i][0]).length === 0) {GM_setValue(menu_ALL[i][0], '')} // 修改旧版类型
6263
menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){customLittleTail()});
6364
} else {
6465
menu_ID[i] = GM_registerMenuCommand(`${menu_ALL[i][3]?'✅':'❎'} ${menu_ALL[i][1]}`, function(){menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
@@ -163,15 +164,15 @@
163164
showPosts(); // 自动显示帖子内被隐藏的回复
164165
blockUsers('thread'); // 屏蔽用户(黑名单)
165166
if (menu_value('menu_onlineStatus')) onlineStatus(); // 显示是否在线
166-
littleTail('thread'); // 小尾巴
167+
replyCustom('thread'); // 回复自定义
167168
} else if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1) { // 各板块帖子列表
168169
curSite = DBSite.forum;
169170
if (menu_value('menu_collapsedNowPost')) collapsedNowPost(); // 收起当前帖子预览(左键左右两侧空白处)
170171
if (menu_value('menu_delate255')) delate255(); // 自动隐藏阅读权限 255 的帖子
171172
blockUsers('forum'); // 屏蔽用户(黑名单)
172173
blockKeywords(); // 屏蔽关键词(帖子标题)
173174
vfastpostDOMNodeInserted(); // 监听插入事件(预览快速回复带签名)
174-
littleTail('forum'); // 小尾巴
175+
replyCustom('forum'); // 回复自定义
175176
if (patt_forum.test(location.pathname)) blockDOMNodeInserted(); //监听插入事件(有新的回复主题,点击查看)
176177
}else if (location.search.indexOf('mod=guide') > -1) { // 导读帖子列表
177178
curSite = DBSite.guide;
@@ -185,7 +186,7 @@
185186
} else if(location.search.indexOf('mod=space') > -1 && location.search.indexOf('&view=me') > -1) { // 别人的主题/回复
186187
curSite = DBSite.youreply;
187188
} else if(location.pathname === '/forum.php' && location.search.indexOf('mod=post&action=reply') > -1 || location.pathname === '/forum.php' && location.search.indexOf('mod=post&action=newthread') > -1) { // 回复:高级回复
188-
littleTail('reply'); // 小尾巴
189+
replyCustom('reply'); // 回复自定义
189190
}
190191

191192
curSite.pageUrl = ""; // 下一页URL
@@ -368,7 +369,7 @@
368369
function customLittleTail() {
369370
let newLittleTail = prompt('编辑 [自定义小尾巴内容],刷新网页后生效(换行请使用 \\n\n提示①:记得在小尾巴前面加上几个 \\n 换行,用来分隔开回帖内容~\n提示②:建议使用 [align=right] 标签来使小尾巴居右~\n提示③:支持论坛富文本标签(建议先找个回复编辑预览好~\n示例:\\n\\n\\n\\n[align=right]第一行内容~\\n第二行内容~[/align]', GM_getValue('menu_customLittleTail'));
370371
if (newLittleTail === '') {
371-
GM_setValue('menu_customLittleTail', []);
372+
GM_setValue('menu_customLittleTail', '');
372373
registerMenuCommand(); // 重新注册脚本菜单
373374
} else if (newLittleTail != null) {
374375
GM_setValue('menu_customLittleTail', newLittleTail);
@@ -377,24 +378,23 @@
377378
};
378379

379380

380-
// 小尾巴
381-
function littleTail(type) {
382-
if (!menu_value('menu_customLittleTail')) return
381+
// 回复自定义
382+
function replyCustom(type) {
383383
switch(type) {
384384
case 'forum': // 各版块帖子列表的预览帖子
385-
littleTail_0(); // 预览帖子 快速回复(底部)
386-
littleTail_1(); // 预览帖子 回复(悬浮)
385+
replyCustom_0(); // 预览帖子 快速回复(底部)
386+
replyCustom_1(); // 预览帖子 回复(悬浮)
387387
break;
388388
case 'thread': // 帖子内
389-
littleTail_1(); // 快速回复(悬浮)
390-
littleTail_2(); // 回复框(底部)
389+
replyCustom_1(); // 快速回复(悬浮)
390+
replyCustom_2(); // 回复框(底部)
391391
break;
392392
case 'reply': // 高级回复
393-
littleTail_3();
393+
replyCustom_3();
394394
break;
395395
}
396396

397-
function littleTail_0() {
397+
function replyCustom_0() {
398398
let vfastpost = e => {
399399
if (e.target.innerHTML && e.target.innerHTML.indexOf('id="vfastpost"') > -1) {
400400
let message = e.target.querySelector('input[name="message"]'), id = message.id.match(/\d+/g)[0];
@@ -407,7 +407,7 @@
407407
document.addEventListener('DOMNodeInserted', vfastpost); // 监听插入事件
408408
}
409409

410-
function littleTail_1() {
410+
function replyCustom_1() {
411411
let floatlayout_reply = e => {
412412
if (e.target.innerHTML && e.target.innerHTML.indexOf('id="floatlayout_reply"') > -1) {
413413
document.getElementById('postsubmit').onclick = function(){
@@ -418,13 +418,13 @@
418418
document.addEventListener('DOMNodeInserted', floatlayout_reply); // 监听插入事件
419419
}
420420

421-
function littleTail_2() { // 帖子底部的回复框
421+
function replyCustom_2() { // 帖子底部的回复框
422422
document.getElementById('fastpostsubmit').onclick = function(){
423423
if (GM_getValue('menu_customLittleTail')) document.getElementById('fastpostmessage').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');
424424
}
425425
}
426426

427-
function littleTail_3() {
427+
function replyCustom_3() {
428428
let postsubmit = document.getElementById('postsubmit');
429429
if (postsubmit && postsubmit.innerText === '\n参与/回复主题\n' || postsubmit && postsubmit.innerText === '\n发表帖子\n') {
430430
postsubmit.onclick = function(){

0 commit comments

Comments
 (0)