您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
使你的小码王更易于使用
当前为
// ==UserScript== // @name 更好的小码王自动化脚本 // @version 1.1.0 // @description 使你的小码王更易于使用 // @author 红石镐&Copilot // @match https://world.xiaomawang.com/* // @icon https://world.xiaomawang.com/favicon.ico // @license MIT // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @namespace https://gf.qytechs.cn/users/1254226 // ==/UserScript== (function() { 'use strict'; // 初始化设置 const settings = { autoReceive: GM_getValue('autoReceive', true), autoSignIn: GM_getValue('autoSignIn', true), autoLoadComments: GM_getValue('autoLoadComments', true), autoExpandReplies: GM_getValue('autoExpandReplies', true) // 新增设置项 }; // 注册(不可用)设置菜单命令 GM_registerMenuCommand('设置', openSettingsDialog); // 打开设置对话框 function openSettingsDialog() { let dialog = document.createElement('div'); dialog.innerHTML = ` <style> /* 添加一些基本的样式 */ .settings-dialog { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1000; padding: 20px; background-color: white; border: 1px solid #ccc; box-shadow: 0 2px 10px rgba(0,0,0,0.5); } .settings-dialog label { display: block; margin-bottom: 10px; } .settings-dialog input[type="checkbox"] { margin-right: 10px; } .settings-dialog button { margin-right: 10px; } </style> <div class="settings-dialog"> <label><input type="checkbox" name="autoReceive" ${settings.autoReceive ? 'checked' : ''}> 自动领取奖励</label> <label><input type="checkbox" name="autoSignIn" ${settings.autoSignIn ? 'checked' : ''}> 自动签到</label> <label><input type="checkbox" name="autoLoadComments" ${settings.autoLoadComments ? 'checked' : ''}> 自动加载评论</label> <label><input type="checkbox" name="autoExpandReplies" ${settings.autoExpandReplies ? 'checked' : ''}> 自动展开子回复</label> <!-- 新增设置项 --> <button id="save-settings">保存</button> <button id="cancel-settings">取消</button> </div> `; document.body.appendChild(dialog); // 绑定保存按钮事件 document.getElementById('save-settings').addEventListener('click', function() { settings.autoReceive = document.querySelector('input[name="autoReceive"]').checked; settings.autoSignIn = document.querySelector('input[name="autoSignIn"]').checked; settings.autoLoadComments = document.querySelector('input[name="autoLoadComments"]').checked; settings.autoExpandReplies = document.querySelector('input[name="autoExpandReplies"]').checked; // 新增设置项 // 保存设置 GM_setValue('autoReceive', settings.autoReceive); GM_setValue('autoSignIn', settings.autoSignIn); GM_setValue('autoLoadComments', settings.autoLoadComments); GM_setValue('autoExpandReplies', settings.autoExpandReplies); // 新增设置项 // 弹出通知 if (window.confirm('更改的设置需刷新后生效,是否刷新?')) { window.location.reload(); } // 关闭对话框 dialog.remove(); }); // 绑定取消按钮事件 document.getElementById('cancel-settings').addEventListener('click', function() { dialog.remove(); }); } // 根据设置执行功能 if (settings.autoReceive) { // 自动领取奖励的代码... // 检查当前页面是否为任务中心页面 // 定义一个函数来点击领取按钮 function clickReceive() { var receiveButton = document.querySelector("div.taskAction__3nOcF.taskReceiveReward__16CiZ"); if (receiveButton && receiveButton.textContent === "领取") { receiveButton.click(); } } // 设置一个间隔,每隔1秒钟调用一次函数 setInterval(clickReceive, 1000); } if (settings.autoSignIn) { // 自动签到的代码... // 检查当前页面是否为首页 if (window.location.href.includes('/w/index')) { // 找到网页中类名为"goTaskCenter__h4wru"且文本内容为"签到"的按钮元素 var signInButton = document.evaluate("//div [@class='goTaskCenter__h4wru' and text()='签到']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; // 检查按钮是否存在 if (signInButton) { // 定义一个函数来点击按钮 function clickSignInButton() { // 检查网页中是否包含“已领取”文字 if (document.body.textContent.includes("已领取")) { // 停止侦测签到按钮 clearInterval(signInInterval); } else { // 点击按钮 signInButton.click(); } } // 设置一个间隔,每隔1秒钟调用一次函数 var signInInterval = setInterval(clickSignInButton, 1000); } } } if (settings.autoLoadComments) { // 自动加载评论的代码... // 检查当前页面是否有“查看更多评论”的按钮 setInterval(function() { // 使用CSS选择器找到“查看更多评论”的按钮元素 var moreCommentsButton = document.querySelector('span.iconfont.icon-shequ-xiala.more-comment-icon__2Bxj9'); // 如果按钮存在 if (moreCommentsButton) { // 点击按钮 moreCommentsButton.click(); } }, 1000); } if (settings.autoExpandReplies) { // 自动展开子回复的代码... setInterval(function() { // 使用XPath选择器找到“共*条回复”的元素 var replyMoreButton = document.evaluate("//span[contains(@class, 'reply-more-button-text__iB2jQ')]", document, null, XPathResult.ANY_TYPE, null); var button = replyMoreButton.iterateNext(); while (button) { // 点击按钮 button.click(); button = replyMoreButton.iterateNext(); } }, 1000); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址