菜单版—回帖检测脚本
原帖:水贴特化—回帖检测脚本在此基础上,主要加了菜单,方便修改设置我原本是想如果浏览器打开了“提醒”网页,就不自动关闭和自动跳转,方便回复别人的,但是那样脚本就太慢了搞了两种菜单的显示形式第一种:显示在网页右下角能实时更新
第二种:在油猴的菜单里因为油猴选项需要刷新网页才能更新,所以我改成了点击之后新建一个例如:(当然,刷新之后又会正常显示三个选项)嗯,第一种方便一点,第二张美观一点?
需要点击设置,修改成自己的uid需要点击设置,修改成自己的uid需要点击设置,修改成自己的uid
第一种
//@Name
// ==UserScript==
// @name:zh-CN 我水贴了吗
// @name Am_I_+2?
// @include https://www.gamemale.com/*
// ==/UserScript==
(async () => {
"use strict";
let userId = 679483; // 你的用户 ID
let autoCloseReplied = true; // 已回帖的网站是否自动关闭
let autoJumpForum = true; // 是否自动跳转到帖子第一页
let autoCloseDelay = 10; // 自动关闭页面的延迟时间,单位为毫秒
const menuAll = `
<div id="am-i-plus2-menu" style="position: fixed; bottom: 10px; right: 10px; z-index: 999;">
<div>
<span>自动关闭:</span>
<span id="auto-close">${autoCloseReplied ? "✅" : "❌"}</span>
</div>
<div>
<span>自动跳转:</span>
<span id="auto-jump">${autoJumpForum ? "✅" : "❌"}</span>
</div>
<div>
<span id="settings-btn"><i class="fas fa-cog"></i>设置#️⃣</span>
</div>
</div>
`;
const setSettings = () => {
const savedSettings = localStorage.getItem("am-i-plus2-settings");
let savedUserId = userId;
let savedAutoCloseDelay = autoCloseDelay;
if (savedSettings) {
const { userId: savedUserIdFromStorage, autoCloseDelay: savedAutoCloseDelayFromStorage } = JSON.parse(savedSettings);
savedUserId = savedUserIdFromStorage;
savedAutoCloseDelay = savedAutoCloseDelayFromStorage;
}
const userIdInput = prompt("请输入用户ID", savedUserId);
if (userIdInput !== null) {
userId = Number(userIdInput);
}
const autoCloseDelayInput = prompt("请输入自动关闭时间(毫秒)", savedAutoCloseDelay);
if (autoCloseDelayInput !== null) {
autoCloseDelay = Number(autoCloseDelayInput);
}
localStorage.setItem("am-i-plus2-settings", JSON.stringify({ userId, autoCloseReplied, autoJumpForum, autoCloseDelay }));
};
const setAutoClose = () => {
autoCloseReplied = !autoCloseReplied;
autoCloseBtn.textContent = autoCloseReplied ? "✅" : "❌";
localStorage.setItem("am-i-plus2-settings", JSON.stringify({ userId, autoCloseReplied, autoJumpForum, autoCloseDelay }));
};
const setAutoJump = () => {
autoJumpForum = !autoJumpForum;
autoJumpBtn.textContent = autoJumpForum ? "✅" : "❌";
localStorage.setItem("am-i-plus2-settings", JSON.stringify({ userId, autoCloseReplied, autoJumpForum, autoCloseDelay }));
};
document.body.insertAdjacentHTML("beforeend", menuAll);
const autoCloseBtn = document.querySelector("#auto-close");
const autoJumpBtn = document.querySelector("#auto-jump");
const settingsBtn = document.querySelector("#settings-btn");
autoCloseBtn.addEventListener("click", setAutoClose);
autoJumpBtn.addEventListener("click", setAutoJump);
settingsBtn.addEventListener("click", setSettings);
const savedSettings = localStorage.getItem("am-i-plus2-settings");
if (savedSettings) {
const { userId: savedUserId, autoCloseReplied: savedAutoCloseReplied, autoJumpForum: savedAutoJumpForum, autoCloseDelay: savedAutoCloseDelay } = JSON.parse(savedSettings);
userId = savedUserId;
autoCloseReplied = savedAutoCloseReplied;
autoJumpForum = savedAutoJumpForum;
autoCloseDelay = savedAutoCloseDelay;
autoCloseBtn.textContent = autoCloseReplied ? "✅" : "❌";
autoJumpBtn.textContent = autoJumpForum ? "✅" : "❌";
}
const isDiscuz = typeof discuz_uid !== "undefined";
let testUrl = location.href;
if (/^https:\/\/www\.gamemale\.com\/forum\.php\?mod=viewthread&tid=\d+/.test(testUrl)) {
const tid = testUrl.match(/tid=(\d+)/);
testUrl = `https://www.gamemale.com/thread-${tid}-1-1.html`;
}
try {
const res = await fetch(`https://www.gamemale.com/forum.php?mod=viewthread&tid=${tid}&page=1&authorid=${userId}`);
const html = await res.text();
const replied = html.includes("发表于");
if (replied) {
if (autoCloseReplied) {
setTimeout(() => {
window.close();
}, autoCloseDelay);
}
}
if (isDiscuz) {
const btnArea = document.querySelector("#postlist td.plc div.authi>span.none") ?? document.querySelector("#postlist td.plc div.authi>span.pipe");
const tips = document.createElement("a");
tips.textContent = replied ? "✅已回帖" : "❌没回贴";
tips.style.marginLeft = "10px";
tips.style.color = replied ? "green" : "red";
btnArea.insertBefore(tips, btnArea.lastElementChild);
} else {
const btnArea = document.querySelector("#postlist > div:first-child .authi");
const tips = document.createElement("span");
tips.textContent = replied ? "✅已回帖" : "❌没回贴";
tips.style.marginLeft = "10px";
tips.style.color = replied ? "green" : "red";
btnArea.appendChild(tips);
}
if (autoJumpForum && !replied) {
const topUrl = `https://www.gamemale.com/thread-${tid}-1-1.html#top`;
location.href = topUrl;
}
} catch (error) {
console.error(error);
}
})();
第二种
//@Name
// ==UserScript==
// @name Am_I_+2
// @name:zh-CN 我水贴了吗 ?
// @include https://www.gamemale.com/*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(async () => {
"use strict";
const userId = GM_getValue("userid", 679483); // 你的用户 ID
const autoCloseReplied = GM_getValue("autoClose", true); // 已回帖的网站是否自动关闭
const autoJumpForum = GM_getValue("autoJump", true); // 是否自动跳转到帖子第一页
const autoCloseDelay = GM_getValue("autoCloseDelay", 10); // 自动关闭页面的延迟时间,单位为毫秒
const setSettings = () => {
const savedUserId = GM_getValue("userid", userId);
const savedAutoCloseDelay = GM_getValue("autoCloseDelay", autoCloseDelay);
const userIdInput = prompt("请输入用户ID", savedUserId);
if (userIdInput !== null) {
GM_setValue("userid", Number(userIdInput));
}
const autoCloseDelayInput = prompt("请输入自动关闭时间(毫秒)", savedAutoCloseDelay);
if (autoCloseDelayInput !== null) {
GM_setValue("autoCloseDelay", Number(autoCloseDelayInput));
}
};
const setAutoClose = () => {
const newAutoCloseReplied = !autoCloseReplied;
GM_setValue("autoClose", newAutoCloseReplied);
const icon = newAutoCloseReplied ? "✅" : "❌";
const menuText = `自动关闭:${icon} ${newAutoCloseReplied ? "已开启" : "已关闭"}`;
GM_registerMenuCommand(menuText, setAutoClose);
const tips = document.querySelector("#autoCloseTips");
tips.textContent = `${icon} ${newAutoCloseReplied ? "已开启" : "已关闭"}`;
};
const setAutoJump = () => {
const newAutoJumpForum = !autoJumpForum;
GM_setValue("autoJump", newAutoJumpForum);
const icon = newAutoJumpForum ? "✅" : "❌";
const menuText = `自动跳转:${icon} ${newAutoJumpForum ? "已开启" : "已关闭"}`;
GM_registerMenuCommand(menuText, setAutoJump);
const tips = document.querySelector("#autoJumpTips");
tips.textContent = `${icon} ${newAutoJumpForum ? "已开启" : "已关闭"}`;
};
const autoCloseIcon = autoCloseReplied ? "✅" : "❌";
const autoCloseColor = autoCloseReplied ? "green" : "red";
GM_registerMenuCommand(`自动关闭:${autoCloseIcon} ${autoCloseReplied ? "已开启" : "已关闭"}`, setAutoClose);
const autoJumpIcon = autoJumpForum ? "✅" : "❌";
const autoJumpColor = autoJumpForum ? "green" : "red";
GM_registerMenuCommand(`自动跳转:${autoJumpIcon} ${autoJumpForum ? "已开启" : "已关闭"}`, setAutoJump);
GM_registerMenuCommand("设置", setSettings);
const isDiscuz = typeof discuz_uid !== "undefined";
let testUrl = location.href;
if (/^https:\/\/www\.gamemale\.com\/forum\.php\?mod=viewthread&tid=\d+/.test(testUrl)) {
const tid = testUrl.match(/tid=(\d+)/);
testUrl = `https://www.gamemale.com/thread-${tid}-1-1.html`;
}
try {
const res = await fetch(`https://www.gamemale.com/forum.php?mod=viewthread&tid=${tid}&page=1&authorid=${userId}`);
const html = await res.text();
const replied = html.includes("发表于");
if (replied && autoCloseReplied) {
setTimeout(() => {
window.close();
}, autoCloseDelay);
}
const btnArea = isDiscuz ? document.querySelector("#postlist td.plc div.authi>span.none") ?? document.querySelector("#postlist td.plc div.authi>span.pipe") : document.querySelector("#postlist > div:first-child .authi");
const tips = document.createElement(isDiscuz ? "a" : "span");
tips.textContent = `${replied ? "✅" : "❌"} ${replied ? "已回帖" : "未回帖"}`;
tips.style.marginLeft = "10px";
tips.style.color = replied ? "green" : "red";
btnArea.appendChild(tips);
if (!replied && autoJumpForum) {
const topUrl = `https://www.gamemale.com/thread-${tid}-1-1.html#top`;
location.href = topUrl;
}
const autoCloseTips = document.createElement("span");
autoCloseTips.id = "autoCloseTips";
autoCloseTips.textContent = `${autoCloseIcon} ${autoCloseReplied ? "已开启" : "已关闭"}`;
autoCloseTips.style.marginLeft = "10px";
autoCloseTips.style.color = autoCloseColor;
btnArea.appendChild(autoCloseTips);
const autoJumpTips = document.createElement("span");
autoJumpTips.id = "autoJumpTips";
autoJumpTips.textContent = `${autoJumpIcon} ${autoJumpForum ? "已开启" : "已关闭"}`;
autoJumpTips.style.marginLeft = "10px";
autoJumpTips.style.color = autoJumpColor;
btnArea.appendChild(autoJumpTips);
} catch (error) {
console.error(error);
}
})();
我的其他脚本:
GM简化禁止b站视频自动播放引鸡 这个回帖检测脚本的功能真的是越来越全面了呢 太好了,可以更和谐()地回帖了{:4_91:} 本帖最后由 一只随行 于 2023-5-25 13:08 编辑
回帖检测也进一步优化了,可惜水漫金山的时代已经过去哩{:6_190:}
就是,有没有可能,过滤掉自己发的帖子呢,不然回复下别人还要关掉自动关闭功能{:6_164:}
这样方便很多了呢,满足了强迫症 吼~手机也行的欸~但咱还以为是右下角能显示是否回帖的呢~
对了,请问能优化脚本吗~有时打开后加载好一会才会显示的,咱现在一般都关了的(´×ω×`) 越来越高级了呀,这个脚本真的是很大的避免了重复回帖 水贴的时代结束力,
不过我基本只要有个能显示是不是已经回复过的就满足了 感谢大佬的脚本福利,自动关闭回过的帖子,回帖越来越有效率了{:4_93:} 菜单更改设置更加方便惹,感谢升级改造{:6_163:} 0-0 妈呀 现在是越来越方便了 日新月异jpg 最近不怎么水贴了完全没有这种烦恼,不过以前倒是经常看到水比重复水贴 技术大佬考虑的真是周到。 能手动开关的脚本,看起来好高级呢。 omg~这个功能真的好方便!!! 直接复制代码到油猴就行了嘛 回帖检测真好用,感谢分享好用的脚本{:4_114:}
对某些水怪来说非常有帮助 真是厉害了呢,大水怪的福音 好耶!这下回帖方便多了;P