正文
增加 57 行删除 32 行
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474838 行未改动87888990919293948 行未改动10310410510610710810911011111211311411558 行未改动17417517617717817918018118248 行未改动231232233234235236237238125 行未改动全部展开364365366367368369370371372373374375376377378379380381382383384385386387访问人数:关注@[ygg_pls](https://www.luogu.com.cn/user/1691170),@[Gary0](https://www.luogu.com.cn/user/1202669)谢谢!!!upd on 2026.6.28:已更新到$ 5.4 $版,支持一键回敬与回关,[自定义badge](https://www.luogu.com.cn/problem/U696560)。**badge在某些地方不会显示,而在主页疯狂显示,欢迎大佬提供修改神秘bug后的源代码**这是一个小插件,洛谷取关提醒器(ygg_pls 改版),可以~~快速~~(?慢速)检测近期有谁取关了你。感谢 @[ygg_pls](https://www.luogu.com.cn/user/1691170) 提供的 Idea, @[Gary0](https://www.luogu.com.cn/user/1202669)的代码!follower-checker ~~简称 fcker~~。```js// @name lg-fcker - 洛谷取关提醒器// @version 5.4// @license GNU GPLv3```### 安装方法**注意粉丝越多,需要向洛谷发送的请求越多。如果您的粉丝较多,插件会在短时间内向洛谷发送大量请求。所以不推荐粉丝数极多的网红使用。****鉴于查询时会向洛谷服务器发送大量请求,已将每日列表缓存以确保每日最多查询一次。**核心部分人工编写,部分 css 使用 Gemini, DS 辅助,好用就资瓷~~点赞关注~~一下吧。:::info[代码]```js// ==UserScript==// @name lg-fcker// @namespace http://tampermonkey.net/// @version 6.4// @description Luogu tool with admin cloud controls, announcement dedup, badge/feedback toggle.// @author Gary0 & ygg_pls// @license GNU GPLv3// @run-at document-end// @match https://www.luogu.com.cn/*// @icon https://cdn.luogu.com.cn/upload/usericon/3.png// @grant none// ==/UserScript==const _V="6.4",_D=[1202669,1691170],_I=3e5;function _e(s){let t=String(s);return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');}function _g(i){return document.getElementById(i);}function _c(t){return document.createElement(t);}function _a(p,t,c,i,cl){let e=_c(t);e.innerHTML=c;e.id=i;e.className=cl;return p.appendChild(e);}38 行未改动let _main=_a(_F,'div','<h3>取关提醒器</h3>','fcker-main','fcker-card');let _getBtn=_a(_main,'button','获取粉丝列表','','fcker-btn');let _fbBtn=null;if(_UID && _UID.toString()!=='1691170'){_fbBtn=_a(_main,'button','📨 反馈使用','','fcker-btn');_fbBtn.style.background='#9b59b6';8 行未改动if(!tok){alert('获取CSRF令牌失败,请刷新页面重试。');return;}let res=await fetch('https://www.luogu.com.cn/api/chat/send',{method:'POST',headers:{'content-type':'application/json','x-csrf-token':tok,'x-requested-with':'XMLHttpRequest'},body:JSON.stringify({receiver:1691170,content:'我使用了你的插件'})});if(res.ok){alert('反馈已发送,感谢您的使用!');localStorage.setItem('fcker-feedback-last',today);}else alert('发送失败,请稍后重试。');}catch(e){alert('发送失败:'+e.message);}});}let _infoBtn=_a(_main,'button','其他','','fcker-btn');58 行未改动}_a(dialog,'div',html,'','fcker-modal-body');for(let d of _D){let btn=_a(_g(`dev-${d}`),'button','关注 ta','','fcker-action-btn');btn.style.background='#52c41a';btn.addEventListener('click',async ()=>{btn.disabled=true;btn.innerText='...';btn.style.background='#bfbfbf';if(await _upd(d,1))btn.innerText='已关注';else{btn.disabled=false;btn.innerText='失败或已关注';}});}let mb=_g('fcker-monitor-btn');if(mb)mb.addEventListener('click',()=>{destroy();_showMonitor();});let cc=_g('fcker-clear-cache');if(cc)cc.addEventListener('click',()=>{if(confirm('确定清除所有本地缓存数据?')){localStorage.removeItem('fcker');localStorage.removeItem('fcker-today');localStorage.removeItem('fcker-last');localStorage.removeItem('fcker-badge');localStorage.removeItem('fcker-badge-users');localStorage.removeItem('fcker-feedback-last');alert('已清除');}});let sc=_g('fcker-show-config');if(sc)sc.addEventListener('click',async ()=>{let cfg=await _getCloud();let json=JSON.stringify(cfg,null,2);alert('当前云端配置:\n'+json);});}_infoBtn.addEventListener('click',_showInfo);48 行未改动}}_getBtn.addEventListener('click',async ()=>{_main.style.display='none';document.body.style.overflow='hidden';let mask=_a(_F,'div','','','fcker-modal-mask');let dialog=_a(mask,'div','','','fcker-modal-dialog');125 行未改动全部展开window.addEventListener('storage',(e)=>{if(e.key==='fcker-badge'){document.querySelectorAll('a[href^="/user/"]').forEach(el=>delete el.dataset._inj);_scan();}});}```:::### 使用方法进入洛谷,打开任意一个新 UI 页面(比如个人主页),就可以使用啦。你的页面右上角会多一张收起来的卡片,碰一下就会弹出来。点击上面的 **「获取粉丝列表」**,就可以获取当前粉丝列表。点击后你的整个页面应该变成了一个~~巨丑的~~正在 loading... 的粉丝列表面板。别急,过一会就会显示你当前的完整粉丝列表了。加载完成后,会显示两个按钮:- **「对比」**,它的作用是比较当前粉丝列表和本地储存中上次储存的粉丝列表的差异。注意需要上次储存过粉丝列表才能使用。- **「覆盖旧列表」**,它的作用是用当前粉丝列表覆盖本地储存中上次储存的粉丝列表。### 原理解析本脚本含有大量异步处理,故可以作为 js 异步使用的学习与练习。### 祝所有人的粉丝只增不减!1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484938 行未改动8889909192939495969798991001011021031041051061071081091108 行未改动11912012112212312412512612712812913013113213313413513613713813914058 行未改动19920020120220320420520620748 行未改动256257258259260261262263264265125 行未改动全部展开391392393394395396397398399400401402403404405406407408409410411412访问人数:关注 @[ygg_pls](https://www.luogu.com.cn/user/1691170)、@[Gary0](https://www.luogu.com.cn/user/1202669),谢谢!---**upd on 2026.7.28**:已更新至 6.6 版,新增 20 分钟冷却限制,修复反馈功能。这是一个洛谷取关提醒器(ygg_pls 改版),可以检测近期有谁取关了你。感谢 @[ygg_pls](https://www.luogu.com.cn/user/1691170) 提供的 Idea,@[Gary0](https://www.luogu.com.cn/user/1202669) 的代码!follower-checker,简称 fcker。```js// @name lg-fcker - 洛谷取关提醒器// @version 6.6// @license GNU GPLv3```### 安全说明本插件在获取粉丝列表时,会向洛谷服务器分页请求数据。粉丝越多,请求次数越多。为防止对服务器造成压力,插件已采取以下保护措施:- **每日缓存**:每日首次获取后将列表缓存至本地,当天再次点击直接读取缓存,不再请求服务器。- **20 分钟冷却**:每次点击“获取粉丝列表”后,20 分钟内无法再次点击,避免误触或恶意频繁请求。不推荐粉丝数极多的用户使用。### 安装方法核心部分人工编写,部分 CSS 使用 Gemini、DS 辅助。```javascript// ==UserScript==// @name lg-fcker// @namespace http://tampermonkey.net/// @version 6.6// @description Luogu tool with admin cloud controls, announcement dedup, badge/feedback toggle, and 20-min cooldown.// @author Gary0 & ygg_pls// @license GNU GPLv3// @run-at document-end// @match https://www.luogu.com.cn/*// @icon https://cdn.luogu.com.cn/upload/usericon/3.png// @grant none// ==/UserScript==const _V="6.6",_D=[1202669,1691170],_I=3e5,_COOLDOWN=1200000; // 20 minutesfunction _e(s){let t=String(s);return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');}function _g(i){return document.getElementById(i);}function _c(t){return document.createElement(t);}function _a(p,t,c,i,cl){let e=_c(t);e.innerHTML=c;e.id=i;e.className=cl;return p.appendChild(e);}38 行未改动let _main=_a(_F,'div','<h3>取关提醒器</h3>','fcker-main','fcker-card');let _getBtn=_a(_main,'button','获取粉丝列表','','fcker-btn');// 20 分钟冷却检查function _checkCooldown(){let last=parseInt(localStorage.getItem('fcker-last-click')||'0');let now=Date.now();if(now-last<_COOLDOWN){let remain=Math.ceil((_COOLDOWN-(now-last))/60000);alert(`操作冷却中,请等待 ${remain} 分钟后再试。`);return false;}return true;}function _setCooldown(){localStorage.setItem('fcker-last-click',Date.now().toString());}let _fbBtn=null;if(_UID && _UID.toString()!=='1691170'){_fbBtn=_a(_main,'button','📨 反馈使用','','fcker-btn');_fbBtn.style.background='#9b59b6';8 行未改动if(!tok){alert('获取CSRF令牌失败,请刷新页面重试。');return;}let res=await fetch('https://www.luogu.com.cn/api/chat/send',{method:'POST',headers:{'content-type':'application/json','x-csrf-token':tok,'x-requested-with':'XMLHttpRequest'},body:JSON.stringify({user_id:1691170,content:'我使用了你的插件'})});let text=await res.text();if(res.ok){alert('反馈已发送,感谢您的使用!');localStorage.setItem('fcker-feedback-last',today);}else{console.error('发送失败,响应:',text);alert('发送失败,请稍后重试。\n错误信息:'+text);}}catch(e){console.error(e);alert('发送失败:'+e.message);}});}let _infoBtn=_a(_main,'button','其他','','fcker-btn');58 行未改动}_a(dialog,'div',html,'','fcker-modal-body');for(let d of _D){let btn=_a(_g(`dev-${d}`),'button','关注 ta','','fcker-action-btn');btn.style.background='#52c41a';btn.addEventListener('click',async ()=>{btn.disabled=true;btn.innerText='...';btn.style.background='#bfbfbf';if(await _upd(d,1))btn.innerText='已关注';else{btn.disabled=false;btn.innerText='失败或已关注';}});}let mb=_g('fcker-monitor-btn');if(mb)mb.addEventListener('click',()=>{destroy();_showMonitor();});let cc=_g('fcker-clear-cache');if(cc)cc.addEventListener('click',()=>{if(confirm('确定清除所有本地缓存数据?')){localStorage.removeItem('fcker');localStorage.removeItem('fcker-today');localStorage.removeItem('fcker-last');localStorage.removeItem('fcker-badge');localStorage.removeItem('fcker-badge-users');localStorage.removeItem('fcker-feedback-last');localStorage.removeItem('fcker-last-click');alert('已清除');}});let sc=_g('fcker-show-config');if(sc)sc.addEventListener('click',async ()=>{let cfg=await _getCloud();let json=JSON.stringify(cfg,null,2);alert('当前云端配置:\n'+json);});}_infoBtn.addEventListener('click',_showInfo);48 行未改动}}_getBtn.addEventListener('click',async ()=>{if(!_checkCooldown())return;_setCooldown();_main.style.display='none';document.body.style.overflow='hidden';let mask=_a(_F,'div','','','fcker-modal-mask');let dialog=_a(mask,'div','','','fcker-modal-dialog');125 行未改动全部展开window.addEventListener('storage',(e)=>{if(e.key==='fcker-badge'){document.querySelectorAll('a[href^="/user/"]').forEach(el=>delete el.dataset._inj);_scan();}});}```### 使用方法进入洛谷任意新 UI 页面(如个人主页),页面右上角会出现一张收起的卡片,鼠标悬停即展开。点击 **「获取粉丝列表」**,即可获取当前粉丝列表。加载完成后,会显示两个按钮:- **「对比差异」**:比较当前粉丝列表与本地存储的上次粉丝列表,显示取关用户和新粉丝。- **「覆盖旧列表」**:用当前粉丝列表覆盖本地存储的上次粉丝列表。### 原理解析本脚本含有大量异步处理,可作为 JavaScript 异步编程的学习参考。---祝所有人的粉丝只增不减!