版本比较
洛谷取关提醒
正文
增加 166 行删除 59 行
11234567891011123415561778919101121121314151617272829181920212223242528 行未改动54555657675859606162230 行未改动全部展开29329429529630629729829930030121 行未改动32332432532633632732832933033121 行未改动353354355356366367368357358359360361362370371363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396373397398399376377378400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431380381382432433434435436437438439440441442443444445384385446447448387388389390391392393449450451452453454455395396456457458459460461462463464465466467468398399469470471472473474475476477478479480401402481482483484485486487488489490491492493494495496497498499500405501502503504505506507508509510511512513409514515516517518191 行未改动全部展开71071171271371471571671771871972072172261472372461672572672772861872973073173273373473562562673673773873924 行未改动764765766767659768769770662663664771这是一个小插件,洛谷取关提醒器,可以~~快速~~(?慢速)检测近期有谁取关了你。这是一个小脚本,洛谷取关提醒器,可以快速检测近期有谁取关了你。
```js// ==UserScript==// @name 洛谷取关提醒器// @version 5.0// @description 可以快速检测近期粉丝变化// @author Gary0// @license GNU GPLv3// ==/UserScript==```
### 安装方法
**注意粉丝越多,需要向洛谷发送的请求越多。如果您的粉丝较多,插件会在短时间内向洛谷发送大量请求。所以不推荐粉丝数极多的网红使用。**注意粉丝越多,**首次使用时**需要向洛谷发送的请求越多。如果您的粉丝较多,插件会在短时间内向洛谷发送大量请求。所以不推荐粉丝数极多的用户使用。
**鉴于查询时会向洛谷服务器发送大量请求,已将每日列表缓存以确保每日最多查询一次。**已经优化算法,仅首次使用时需要发送较多请求,后续请求量较少。 鉴于正常情况下没有单日多次查询的需求,已将每日列表缓存以确保每日最多查询一次。
首先你需要一个脚本管理器,然后在[洛谷](https://www.luogu.com.cn/article/ugc80dim)或 [Github](https://github.com/Gary-0925/lg-fckecker/blob/main/main.js) 复制脚本代码,并粘贴保存新脚本。或者您也可以前往 [GreasyFork](https://greasyfork.org/zh-CN/scripts/582602) 安装。首先你需要一个脚本管理器,然后在[洛谷](https://www.luogu.com.cn/article/ugc80dim)或[洛谷档案馆](https://www.luogu.ac.cn/article/ugc80dim)或 [Github](https://github.com/Gary-0925/lg-fckecker/blob/main/main.js) 或 [Github raw](https://raw.githubusercontent.com/Gary-0925/lg-fckecker/refs/heads/main/main.js) 复制脚本代码,并在脚本管理器中粘贴保存为新脚本。或者您也可以前往 [GreasyFork](https://greasyfork.org/zh-CN/scripts/582602) 或 [ScriptCat](https://scriptcat.org/zh-CN/script-show-page/8847) 安装。
核心部分人工编写,部分 css 使用 Gemini 辅助,好用就资瓷一下吧。核心部分人工编写,部分 css 使用 Gemini 辅助,好用就去 Github 点亮 star 蟹蟹喵。
:::info[代码]```js// ==UserScript==// @name 洛谷取关提醒器// @namespace http://tampermonkey.net/// @version 5.0// @description 可以快速检测近期粉丝变化// @namespace Gary0// @author Gary0// @version 6.0// @description 可以快速检测近期粉丝变化// @license GNU GPLv3// @run-at document-end// @match https://www.luogu.com.cn/*// @icon https://cdn.luogu.com.cn/upload/usericon/3.png28 行未改动 const data_json = JSON.stringify(data_ob); return data_json;}
const version = "5.0", devs = [1202669], fchecker = insert_el(document.body, "div", "", "fchecker", "");const version = "6.0", devs = [ 1202669 ], fchecker = insert_el(document.body, "div", "", "fchecker", "");fchecker.style = "position: fixed; top: 0; left: 0; bottom: 0; right: 0; z-index: 1000; pointer-events: none;";
function get_settings_map(){230 行未改动全部展开`);const main = insert_el(fchecker, "div", "<h3>取关提醒器</h3>", "fchecker-main", "fchecker-card");const get_btn = insert_el(main, "button", "获取粉丝列表", "", "fchecker-btn");const set_btn = insert_el(main, "button", "设置", "", "fchecker-btn");const info_btn = insert_el(main, "button", "其他", "", "fchecker-btn");const info_btn = insert_el(main, "button", "关于", "", "fchecker-btn");async function show_get(){ main.style.display = "none"; document.body.style.overflow = "hidden";21 行未改动 const m = html.match(/<script id="lentille-context" type="application\/json">([\s\S]*?)<\/script>/); if (!m) return null; const json = JSON.parse(m[1]); if (!json?.data?.users?.result) return { success: false, data: "页面解析失败" }; return { success: true, data: json.data.users.result }; return { success: true, data: json.data.users.result, count: json.data.users.count }; } async function parse_followers_count(html) { const m = html.match(/<script id="lentille-context" type="application\/json">([\s\S]*?)<\/script>/);21 行未改动 .catch((err) => { return { success: false, data: `获取粉丝数量失败: ${err}` }; }); } async function get_all_followers(uid) { get_card_status.innerText = `loading...`; const cdata = await get_followers_count(uid); if (cdata.success) get_card_status.innerText = `loading... 0%`; const page_cache = new Map(); let total_count = null;
async function fetch_page(p) { const count = cdata.data, pages = Math.ceil(count / 20); if (count > 800) if (page_cache.has(p)) return page_cache.get(p); await sleep(400); const res = await get_followers(uid, p); if (!res.success) return null; if (typeof res.count === "number") total_count = res.count; page_cache.set(p, res.data); return res.data; }
let saved_raw = localStorage.getItem("fchecker"); let old_list = null; if (saved_raw) { try { old_list = JSON.parse(saved_raw); } catch (e) { } }
let p_check = 1; if (old_list && old_list.length > 0) { p_check = Math.floor((old_list.length - 1) / 20) + 1; }
const init_data = await fetch_page(p_check); if (!init_data) { get_card_status.innerText = "获取粉丝列表失败"; return null; }
if (total_count === null) { const cdata = await get_followers_count(uid); if (!cdata.success) { get_card_status.innerText = `您的粉丝页数太多,为防止高频请求导致封号,禁止使用`; get_card_status.innerText = cdata.data; return null; } let nc = 0, success = true, list = [], tasks = []; get_card_status.innerText = `loading... 0 / ${count}`; for (let i = 1; i <= pages; i++) total_count = cdata.data; }
const count = total_count; if (count > 800) { get_card_status.innerText = `您的粉丝页数太多,为防止高频请求导致封号,禁止使用`; return null; } if (count === 0) { get_card_status.innerText = `loading... 100%`; return []; }
let resolved_count = 0; function update_progress(delta) { resolved_count += delta; const pct = Math.min(100, Math.floor(resolved_count / count * 100)); get_card_status.innerText = `loading... ${pct}%`; }
const pages = Math.ceil(count / 20);
if (old_list && old_list.length > 0 && count >= old_list.length) { const n = old_list.length; const offset = (n - 1) % 20; const target_uid = old_list[n - 1].uid; if (init_data.length > offset && init_data[offset].uid === target_uid) { await sleep(1000); let p = get_followers(uid, i).then((res) => { if (res.success && success) let list = old_list.slice(0, n); update_progress(n); if (init_data.length > offset + 1) { const extra = init_data.slice(offset + 1); list.push(...extra); update_progress(extra.length); } let ok = true; for (let p = p_check + 1; p <= pages; p++) { const p_data = await fetch_page(p); if (p_data) { nc += res.data.length, list.push(...res.data); get_card_status.innerText = `loading... ${nc} / ${count}`; list.push(...p_data); update_progress(p_data.length); } else if (!res.success) { success = false; get_card_status.innerText = res.data; } }); tasks.push(p); else { ok = false; break; } } if (ok && list.length === count) { return list; } } await Promise.all(tasks); if (success) }
resolved_count = 0; update_progress(0);
const old_map = new Map(); if (old_list) for (let i = 0; i < old_list.length; i++) old_map.set(old_list[i].uid, i); async function solve(p1, p2) { if (p1 > p2) return []; if (p1 === p2) { if (nc === count) return list; else const data = await fetch_page(p1); if (data) update_progress(data.length); return data; }
if (old_list && old_list.length > 0) { const data1 = await fetch_page(p1); const data2 = await fetch_page(p2); if (!data1 || !data2) return null; if (data1.length > 0 && data2.length > 0) { get_card_status.innerText = "获取粉丝列表失败"; return null; const u1 = data1[0]; const u2 = data2[data2.length - 1]; if (old_map.has(u1.uid) && old_map.has(u2.uid)) { const idx1 = old_map.get(u1.uid); const idx2 = old_map.get(u2.uid); const expected_len = (p2 - p1) * 20 + data2.length; const start_idx = (p1 - 1) * 20; if (idx1 >= start_idx && idx2 - idx1 + 1 === expected_len) { const res = old_list.slice(idx1, idx2 + 1); update_progress(res.length); return res; } } } }
const mid = Math.floor((p1 + p2) / 2); const left = await solve(p1, mid); else return null; if (!left) return null; const right = await solve(mid + 1, p2); if (!right) return null; return left.concat(right); }
const now_list = await solve(1, pages); if (now_list && now_list.length === count) { return now_list; } else { get_card_status.innerText = cdata.data; get_card_status.innerText = "获取粉丝列表失败"; return null; } }
191 行未改动全部展开 quit_btn.addEventListener("click", destroy_modal);
const html = ` <h3>洛谷取关提醒器 ${version}</h3> <p> 已优化算法。<br> 首次使用可能需较长时间获取完整粉丝列表,请耐心等待。后续即可以较快速度获取差异。 </p> <p id="dev-1202669"> by @<a href="https://www.luogu.com.cn/user/1202669">Gary0</a> </p> <p> <h4>更新获取</h4> <a href="https://greasyfork.org/zh-CN/scripts/582602">GreasyFork(推荐)</a> <a href="https://scriptcat.org/zh-CN/script-show-page/8847">ScriptCat(推荐)</a> || <a href="https://github.com/Gary-0925/lg-fchecker/blob/main/main.js">Github</a> <a href="https://github.com/Gary-0925/lg-fchecker/blob/main/main.js">Github(推荐)</a> || <a href="https://greasyfork.org/zh-CN/scripts/582602">GreasyFork</a> || <a href="https://www.luogu.com.cn/article/ugc80dim">洛谷(更新慢)</a> <a href="https://www.luogu.com.cn/article/ugc80dim">洛谷</a> </p> <p> <h4>反馈与建议</h4> <a href="https://www.luogu.com.cn/chat?uid=1202669">洛谷</a> || <a href="https://github.com/Gary-0925/lg-fchecker/pulls">Github</a> || <a href="https://greasyfork.org/zh-CN/scripts/582602/feedback">GreasyFork</a> </p> `; insert_el(dialog, "div", html, "", "fchecker-modal-body");
24 行未改动点击后你的整个页面应该变成了一个~~巨丑的~~正在 loading... 的粉丝列表面板。别急,过一会就会显示你当前的完整粉丝列表了。
加载完成后,会显示两个按钮:
- **「对比」**,它的作用是比较当前粉丝列表和本地储存中上次储存的粉丝列表的差异。注意需要上次储存过粉丝列表才能使用。- **「对比差异」**,它的作用是比较当前粉丝列表和本地储存中储存的粉丝列表的差异。注意需要上次储存过粉丝列表才能使用。- **「覆盖旧列表」**,它的作用是用当前粉丝列表覆盖本地储存中上次储存的粉丝列表。
~~没错我 css 就是 fvv 所以看不惯就自己改吧。~~
### 祝所有人的粉丝只增不减!~~css 很 fvv 所以看不惯就自己改吧。~~