mirror of
https://github.com/XIU2/UserScript.git
synced 2026-09-22 15:06:57 +00:00
优化 代码
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
// @homepageURL https://github.com/XIU2/UserScript
|
||||
// ==/UserScript==
|
||||
|
||||
'use strict';
|
||||
(function() {
|
||||
'use strict';
|
||||
let style_Add = document.createElement('style');
|
||||
style_Add.innerHTML = `
|
||||
[url=home.php?mod=space&uid=945662]@media[/url] (min-width:1366px) {
|
||||
@@ -98,6 +98,6 @@ textarea#fastpostmessage {
|
||||
document.head.appendChild(style_Add);
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
})();
|
||||
@@ -19,8 +19,8 @@
|
||||
// @homepageURL https://github.com/XIU2/UserScript
|
||||
// ==/UserScript==
|
||||
|
||||
'use strict';
|
||||
(function() {
|
||||
'use strict';
|
||||
var menu_ALL = [
|
||||
['menu_autoReply', '自动回复', '自动回复', true],
|
||||
['menu_cleanTopPost', '清理置顶帖子', '清理置顶帖子', true],
|
||||
@@ -186,7 +186,7 @@
|
||||
let checklogin = document.querySelectorAll('.wp.h_menu p a');
|
||||
if (checklogin){
|
||||
for (let value of checklogin) {
|
||||
if (value.innerHTML == "退出"){
|
||||
if (value.textContent == '退出'){
|
||||
loginStatus = true;
|
||||
}
|
||||
}
|
||||
@@ -220,10 +220,10 @@
|
||||
|
||||
// 写入自动回复内容
|
||||
function writeReply(){
|
||||
let textarea = document.getElementById("fastpostmessage");
|
||||
let textarea = document.getElementById('fastpostmessage');
|
||||
if (textarea){
|
||||
textarea.value = textarea.value + replyList[Math.floor((Math.random()*replyList.length))] + replyList[Math.floor((Math.random()*replyList.length))];
|
||||
let fastpostsubmit = document.getElementById("fastpostsubmit");
|
||||
let fastpostsubmit = document.getElementById('fastpostsubmit');
|
||||
if (fastpostsubmit){
|
||||
fastpostsubmit.click();
|
||||
}
|
||||
@@ -233,7 +233,7 @@
|
||||
|
||||
// 清理置顶帖子
|
||||
function cleanTopPost(){
|
||||
let showhide = document.querySelectorAll("a.showhide.y");
|
||||
let showhide = document.querySelectorAll('a.showhide.y');
|
||||
if (showhide.length > 0){
|
||||
showhide.forEach(el=>el.click());
|
||||
}
|
||||
@@ -242,9 +242,7 @@
|
||||
|
||||
// 隐藏帖子内的 [下一页] 按钮
|
||||
function hidePgbtn() {
|
||||
let style_hidePgbtn = document.createElement('style');
|
||||
style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`;
|
||||
document.head.appendChild(style_hidePgbtn);
|
||||
document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +256,7 @@
|
||||
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
|
||||
if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了
|
||||
let autopbn = document.querySelector('#autopbn');
|
||||
if (autopbn && autopbn.innerText == "下一页 »"){ // 如果已经在加载中了,就忽略
|
||||
if (autopbn && autopbn.textContent == '下一页 »'){ // 如果已经在加载中了,就忽略
|
||||
autopbn.click();
|
||||
}
|
||||
}else{
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
// @homepageURL https://github.com/XIU2/UserScript
|
||||
// ==/UserScript==
|
||||
|
||||
'use strict';
|
||||
(function() {
|
||||
'use strict';
|
||||
var menu_ALL = [
|
||||
['menu_rule', '隐藏版规', '隐藏版规', false]
|
||||
], menu_ID = [];
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
// @homepageURL https://github.com/XIU2/UserScript
|
||||
// ==/UserScript==
|
||||
|
||||
'use strict';
|
||||
(function() {
|
||||
'use strict';
|
||||
var menu_ALL = [
|
||||
['menu_autoClockIn', '自动签到', '自动签到', true],
|
||||
['menu_pageLoading', '自动无缝翻页', '自动无缝翻页', true],
|
||||
@@ -191,14 +191,14 @@
|
||||
if (qiandao) {
|
||||
GM_xmlhttpRequest({
|
||||
url: qiandao.href,
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
timeout: 5000,
|
||||
onload: function (response) {
|
||||
let html = ShowPager.createDocumentByString(response.responseText);
|
||||
html = html.querySelector('#messagetext p')
|
||||
if (html && html.innerText.indexOf('任务已完成') > -1 || html && html.innerText.indexOf('已申请过此任务') > -1) {
|
||||
qiandao.querySelector('.qq_bind').setAttribute('src','https://www.52pojie.cn/static/image/common/wbs.png') // 修改 [打卡签到] 图标为 [签到完毕]
|
||||
qiandao.href = "#" // 修改 URL 为 #
|
||||
if (html && html.textContent.indexOf('任务已完成') > -1 || html && html.textContent.indexOf('已申请过此任务') > -1) {
|
||||
qiandao.querySelector('.qq_bind').src = 'https://www.52pojie.cn/static/image/common/wbs.png'; // 修改 [打卡签到] 图标为 [签到完毕] 图标
|
||||
qiandao.href = 'javascript:void(0);'
|
||||
} else {
|
||||
GM_notification({text: '自动签到失败!请联系作者解决!', title: '吾爱破解论坛增强', timeout: 3000});
|
||||
}
|
||||
@@ -229,9 +229,7 @@
|
||||
|
||||
// 隐藏帖子内的 [下一页] 按钮
|
||||
function hidePgbtn() {
|
||||
let style_hidePgbtn = document.createElement('style');
|
||||
style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`;
|
||||
document.head.appendChild(style_hidePgbtn);
|
||||
document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +246,7 @@
|
||||
ShowPager.loadMorePage();
|
||||
} else {
|
||||
let autopbn = document.querySelector(curSite.pager.nextLink);
|
||||
if (autopbn && autopbn.innerText == curSite.pager.nextText) { // 如果正在加载,就不再点击
|
||||
if (autopbn && autopbn.textContent == curSite.pager.nextText) { // 如果正在加载,就不再点击
|
||||
autopbn.click();
|
||||
}
|
||||
}
|
||||
|
||||
+13
-15
@@ -278,7 +278,7 @@
|
||||
listItem.forEach(function(item){ // 遍历所有帖子
|
||||
menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单
|
||||
let itemName = item.querySelector(list2); // 寻找用户名
|
||||
if (itemName && itemName.innerText === item1) {
|
||||
if (itemName && itemName.textContent === item1) {
|
||||
console.log(`屏蔽用户:${item1}`);
|
||||
item.remove(); // 删除帖子
|
||||
}
|
||||
@@ -294,7 +294,7 @@
|
||||
listItem.forEach(function(item){ // 遍历所有回复
|
||||
menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单
|
||||
let itemName = item.querySelector('a.xi2'); // 寻找用户名
|
||||
if (itemName && itemName.innerText === item1) {
|
||||
if (itemName && itemName.textContent === item1) {
|
||||
console.log(`屏蔽用户:${item1}`);
|
||||
item.remove(); // 删除回复
|
||||
}
|
||||
@@ -331,8 +331,8 @@
|
||||
listItem.forEach(function(item){ // 遍历所有帖子标题
|
||||
menu_value('menu_customBlockKeywords').forEach(function(item1){ // 遍历关键词
|
||||
let itemName = item.querySelector('a.s.xst'); // 寻找帖子标题
|
||||
if (itemName && itemName.innerText.indexOf(item1) > -1) {
|
||||
console.log(`屏蔽关键词:[${item1}]`, `,帖子标题:[${itemName.innerText}]`);
|
||||
if (itemName && itemName.textContent.indexOf(item1) > -1) {
|
||||
console.log(`屏蔽关键词:[${item1}]`, `,帖子标题:[${itemName.textContent}]`);
|
||||
item.remove(); // 删除帖子
|
||||
}
|
||||
})
|
||||
@@ -343,7 +343,7 @@
|
||||
// 监听插入事件(有新的回复主题,点击查看)
|
||||
function blockDOMNodeInserted() {
|
||||
let block = e => {
|
||||
if (e.target.innerText && e.target.innerText.indexOf('newthread') > -1) {
|
||||
if (e.target.textContent && e.target.textContent.indexOf('newthread') > -1) {
|
||||
setTimeout(function () {
|
||||
blockUsers('forum'); // 屏蔽用户(黑名单)
|
||||
blockKeywords(); // 屏蔽关键词(帖子标题)
|
||||
@@ -426,7 +426,7 @@
|
||||
|
||||
function replyCustom_3() {
|
||||
let postsubmit = document.getElementById('postsubmit');
|
||||
if (postsubmit && postsubmit.innerText === '\n参与/回复主题\n' || postsubmit && postsubmit.innerText === '\n发表帖子\n') {
|
||||
if (postsubmit && postsubmit.textContent === '\n参与/回复主题\n' || postsubmit && postsubmit.textContent === '\n发表帖子\n') {
|
||||
postsubmit.onclick = function(){
|
||||
if (GM_getValue('menu_customLittleTail')) document.getElementById('e_textarea').value += GM_getValue('menu_customLittleTail').replaceAll('\\n', '\n');
|
||||
}
|
||||
@@ -438,7 +438,7 @@
|
||||
// 监听插入事件(回帖间隔)
|
||||
/*function replyIntervalDOMNodeInserted() {
|
||||
let replyInterval = e => {
|
||||
if (e.target.innerHTML && e.target.innerText.indexOf('发表回复 金钱+1') > -1) {
|
||||
if (e.target.innerHTML && e.target.textContent.indexOf('发表回复 金钱+1') > -1) {
|
||||
setTimeout(function () {GM_notification({text: '过去 60 秒了,可以回帖了~', timeout: 3500});}, 60000)
|
||||
}
|
||||
}
|
||||
@@ -459,9 +459,7 @@
|
||||
|
||||
// 隐藏帖子内的 [下一页] 按钮
|
||||
function hidePgbtn() {
|
||||
let style_hidePgbtn = document.createElement('style');
|
||||
style_hidePgbtn.innerHTML = `.pgbtn {display: none;}`;
|
||||
document.head.appendChild(style_hidePgbtn);
|
||||
document.lastChild.appendChild(document.createElement('style')).textContent = '.pgbtn {display: none;}';
|
||||
}
|
||||
|
||||
|
||||
@@ -496,10 +494,10 @@
|
||||
// 显示在线状态
|
||||
function onlineStatus() {
|
||||
document.querySelectorAll('[id^="favatar"]').forEach(function(item){ // 遍历所有帖子
|
||||
let icon = (item.querySelector('[id^="userinfo"] > .i.y em').innerText === '当前在线') ? '🌝' : '🌚';
|
||||
let icon = (item.querySelector('[id^="userinfo"] > .i.y em').textContent === '当前在线') ? '🌝' : '🌚';
|
||||
let divStatus = document.createElement('div');
|
||||
divStatus.style = 'position: absolute;margin: -8px 0 0 8px;padding: 0 1px 1.2px;background-color: #ffffff;border-radius: 50%;';
|
||||
divStatus.innerText = icon;
|
||||
divStatus.textContent = icon;
|
||||
let mochu = item.querySelector('.avatar');
|
||||
mochu.parentNode.insertBefore(divStatus,mochu);
|
||||
})
|
||||
@@ -511,7 +509,7 @@
|
||||
if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1){
|
||||
let tbody = document.querySelectorAll('tbody[id^="normalthread_"] .xw1');
|
||||
Array.from(tbody).forEach(function (_this) {
|
||||
if (_this.innerText === '255') {
|
||||
if (_this.textContent === '255') {
|
||||
_this.parentNode.parentNode.parentNode.remove();
|
||||
}
|
||||
})
|
||||
@@ -529,10 +527,10 @@
|
||||
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + 999) {
|
||||
if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了
|
||||
let autopbn = document.querySelector('#autopbn');
|
||||
if (autopbn && autopbn.innerText === "下一页 »"){ // 如果已经在加载中了,就忽略
|
||||
if (autopbn && autopbn.textContent === "下一页 »"){ // 如果已经在加载中了,就忽略
|
||||
autopbn.click();
|
||||
let timer = setInterval(function(){ // 在下一页加载完成后
|
||||
if (document.querySelector('#autopbn').innerText === "下一页 »") {
|
||||
if (document.querySelector('#autopbn').textContent === "下一页 »") {
|
||||
if (menu_value('menu_delate255')) delate255(); // 隐藏 255 权限帖子
|
||||
if (menu_value('menu_blockUsers')) blockUsers('forum'); // 屏蔽用户(黑名单)
|
||||
if (menu_value('menu_blockKeywords')) blockKeywords(); // 屏蔽关键词(帖子标题)
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
// @homepageURL https://github.com/XIU2/UserScript
|
||||
// ==/UserScript==
|
||||
|
||||
'use strict';
|
||||
(function() {
|
||||
'use strict';
|
||||
var menu_ALL = [
|
||||
['menu_autoClockIn', '自动签到', '自动签到', true],
|
||||
['menu_linksToImgs', '链接转图片', '链接转图片', true],
|
||||
@@ -245,22 +245,22 @@
|
||||
let url = (location.origin + "/mission/daily/redeem?" + RegExp("once\\=(\\d+)").exec(document.querySelector('div#Top .tools').innerHTML)[0]);
|
||||
GM_xmlhttpRequest({
|
||||
url: url,
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
timeout: 5000,
|
||||
onload: function (response) {
|
||||
let html = ShowPager.createDocumentByString(response.responseText);
|
||||
if (html.querySelector('li.fa.fa-ok-sign')) {
|
||||
html = html.getElementById('Main').innerText.match(/已连续登录 (\d+?) 天/)[0];
|
||||
html = html.getElementById('Main').textContent.match(/已连续登录 (\d+?) 天/)[0];
|
||||
GM_setValue('menu_clockInTime', timeNow); // 写入签到时间以供后续比较
|
||||
console.info('[V2EX 增强] 自动签到完成!')
|
||||
if (qiandao) {
|
||||
qiandao.innerText = `自动签到完成!${html}`;
|
||||
qiandao.href = '#';
|
||||
qiandao.textContent = `自动签到完成!${html}`;
|
||||
qiandao.href = 'javascript:void(0);';
|
||||
}
|
||||
} else {
|
||||
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});}});
|
||||
console.warn('[V2EX 增强] 自动签到失败!请联系作者解决!')
|
||||
if (qiandao) qiandao.innerText = '自动签到失败!请尝试手动签到!';
|
||||
if (qiandao) qiandao.textContent = '自动签到失败!请尝试手动签到!';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
// @homepageURL https://github.com/XIU2/UserScript
|
||||
// ==/UserScript==
|
||||
|
||||
'use strict';
|
||||
(function() {
|
||||
'use strict';
|
||||
var menu_ALL = [
|
||||
['menu_autoReply', '自动回复', '自动回复', true],
|
||||
['menu_pageLoading', '自动无缝翻页', '自动无缝翻页', true],
|
||||
|
||||
Reference in New Issue
Block a user