|
正常使用 不唰唰唰连续搞四五页,应该还是挺稳定的
记得修改成自己的UID 记得修改成自己的UID
//@Name
- // ==UserScript==
- // @name 页面回复检测
- // @version 1.1
- // @description 在帖子列表页上标记你是否回帖
- // @author N&M
- // @icon https://www.google.com/s2/favicons?sz=64&domain=gamemale.com
- // @match https://www.gamemale.com/*
- // @grant GM_addStyle
- // ==/UserScript==
- (function() {
- 'use strict';
- // 输入您的UID
- const userId = '679483';
- // 添加样式
- GM_addStyle(`
- .replied-thread:before {
- content: '✔️';
- margin-right: 5px;
- }
- .unreplied-thread:before {
- content: '❌';
- margin-right: 5px;
- }
- `);
- // 存储缓存结果的对象
- const cache = {};
- // 获取主题帖元素
- const threadElements = document.querySelectorAll('.bm_c tbody[id^="normalthread_"]');
- // 构建请求URL数组
- const requestUrls = Array.from(threadElements).map(threadElement => {
- const threadLinkElement = threadElement.querySelector('.xst');
- const threadUrl = threadLinkElement.getAttribute('href');
- const threadId = threadUrl.match(/thread-(\d+)/)[1];
- return `https://www.gamemale.com/forum.php?mod=viewthread&tid=${threadId}&authorid=${userId}`;
- });
- // 批量请求回帖情况
- Promise.all(requestUrls.map(url => fetch(url).then(res => res.text())))
- .then(responses => {
- responses.forEach((html, index) => {
- const threadElement = threadElements[index];
- const threadUrl = requestUrls[index];
- const threadId = threadUrl.match(/tid=(\d+)/)[1];
- // 判断当前登录用户是否回帖
- const replied = !(html.includes("未定义操作") || html.includes("ERROR:"));
- // 缓存回帖情况
- cache[threadId] = replied;
- // 应用回帖标记样式
- applyReplyStatus(threadElement, replied);
- });
- })
- .catch(error => {
- console.error('An error occurred while fetching replies:', error);
- });
- // 应用回帖标记样式
- function applyReplyStatus(threadElement, replied) {
- if (replied) {
- threadElement.classList.add('replied-thread');
- } else {
- threadElement.classList.add('unreplied-thread');
- }
- }
- })();
复制代码
来自群组: 泥潭疗养院 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
评分
-
查看全部评分
|