guest770129 发布于九月 30, 2023 分享 发布于九月 30, 2023 (已修改) · 只看该作者 我是 Guest770129,一名程序猿。很早就知道 SS 同盟的存在,不过一直以为是一个汉化组之类的。近期才知道是论坛,创帐号努力(水)了几天终于出村了!很感谢新手任务给的大量节操,不然估计还得多水上几天才能出村。 在新手村待的这几天感受到论坛很活泼的氛围,话题的回覆频率、互相讨论的速度,有时候还得反复切回个人页面确认有没有不小心聊到 8 连。在外也会时不时的拿出手机来看网页有没有跳通知。有种回到社交平台刚开始那种很在意互动的时候。 (很多社交软体用久了通知都直接滑掉) 总而言之很高兴能来到这方新天地!也请各位多多指教! 当初在村子里一直很在意什么时候会达标能出村,但又不知道积分数值去哪里看,所以自己顺手写了一段代码可以显示: 【当前积分】 没达到 15 点,会显示差了多少回覆或主题。 【穿越条件】 距离达标还差多少小时、内容数、节操。 规则参考 积分 = 内容数*0.3 + 福源*10 + 节操*0.03 新手上路需要 > 15 积分 一次回覆 = 1 内容 + 新手村回覆 2 节操 新手村主题 +10 节操 注册3天 + 20内容数 + 300节操 + 并等待24-72小时 以下是教学: 首先必须要在能看的到使用者面板的网页才行,因为会抓取个人页面的 URL 然后从元素里提取需要的资料。 △ 使用者面板 打开浏览器(Edge、Chrome、Firefox 都可以,其他浏览器没试过)点击 F12 打开 开发者工具(devtools)。 △ 开发者工具介面 然后在开发者工具上有很多小分页点击 控制台(主控台、console)的分页。会打开一个可以打字的介面。 △ 控制台介面 然后复制以下代码(没有任何恶意代码放心),并贴在控制台内的打字区。 const userUrl = document.getElementById("cUserLink").children[0].href; const userData = await fetch(userUrl); const userHtml = await userData.text(); const parser = new DOMParser(); const doc = parser.parseFromString(userHtml, "text/html"); const data = getData(doc); const [contentNum, joinTime, integrity, luck] = data; // 积分=内容数*0.3+福源*10+节操*0.03 const credit = (contentNum * 0.3 + luck * 10 + integrity * 0.03).toFixed(2); // 新手上路需要 > 15 const needCredit = (15 - credit).toFixed(2); // 一次回覆等于 1 内容 + 新手村回覆 2 节操 // 一次回覆等于 1 内容 + 新手村主题 10 节操 const needCommit = Math.ceil(needCredit / (0.3 + 0.03 * 2)); const needTopic = Math.ceil(needCredit / (0.3 + 0.03 * 10)); const needDateTime = new Date(joinTime); needDateTime.setDate(needDateTime.getDate() + 3); const nowDateTime = new Date(); const timeDiff = needDateTime - nowDateTime; const hourDiff = Math.ceil(timeDiff / (1000 * 60 * 60)); // 注册3天+20内容数+300节操+并等待24-72小时 const canTravel = hourDiff < 0 && contentNum >= 20 && integrity >= 300; const outputText = `【当前积分】:${credit} ${ needCredit > 0 ? `\n还需 ${needCredit} 积分 才能脱离新手村 \n相当于 ${needCommit} 个回覆 或 ${needTopic} 个主题` : "\n恭喜超过 15 点积分!等待 24 小时后会提升为 【新手上路】" } 【穿越条件】 注册 3 天 ${hourDiff > 0 ? `需 ${hourDiff} 小时` : "通过"} 20 内容数 ${contentNum < 20 ? `需 ${20 - contentNum} 内容` : "通过"} 300 节操 ${integrity < 300 ? `需 ${300 - integrity} 节操` : "通过"} ${canTravel ? "符合穿越規則!請等待 24-72 小时。" : "还不能穿越!"} `; console.log(outputText); function getData(document) { const getDataByLi = (liTitle) => [...document.getElementsByTagName("li")].find( (el) => el?.children[0]?.innerText === liTitle ); const getLiNum = (liEl) => liEl.textContent.match(/\d+/)[0]; const getLiDateTime = (liEl) => liEl.children[1].dateTime; const needData = [ { title: "内容数", parser: getLiNum }, { title: "加入", parser: getLiDateTime }, { title: "节操", parser: getLiNum }, { title: "福缘", parser: getLiNum }, ]; const liEls = needData.map(({ title, parser }) => ({ title, parser, el: getDataByLi(title), })); const liData = liEls.map(({ el, parser }) => parser(el)); return liData; } △ 游标闪烁处贴上代码 △ 像这样 然后按下键盘上的 回车键(Enter) 就可以看到目前积分跟穿越条件是否达标。 △ 会显示像这样的字串就成功了! △ 有哪些条件没达成差多少也会这样显示 ※ 如果是喷红色错误欢迎截图给我看。毕竟无程式,不成 BUG。 九月 30, 2023,由guest770129修改 修正 needTopic 错误算法 10节操 > 1 内容 + 10 节操 注释 青山狐仙 45.00节操 欢迎大佬 链接到点评
推荐贴