// ==UserScript== // @name 5号试用版每日脚本 // @version V3.1.2 // @description 自动完成微软Rewards每日搜索任务,每次运行时获取抖音/微博/哔哩哔哩/百度/头条热门词,避免使用同样的搜索词被封号。 // @note 更新于 2025年7月21日 // @author carto // @match https://*.bing.com/* // @exclude https://rewards.bing.com/* // @license GNU GPLv3 // @icon https://www.bing.com/favicon.ico // @connect gumengya.com // @run-at document-end // @grant GM_registerMenuCommand // @grant GM_addStyle // @grant GM_openInTab // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @namespace https://greasyfork.org/zh-CN/scripts/477107 // ==/UserScript== var max_rewards = 22; //重复执行的次数 // 相邻两次搜索的间隔(随机,45秒 ~ 65秒) var search_delay_min = 45000; var search_delay_max = 65000; // 每5次搜索后的停顿(约4.42分钟 ~ 5分钟,即 4分25秒 ~ 5分钟) var pause_base_time = 282500; // 基准 282.5秒 ≈ 4.71分钟 var pause_variance = 17500; // ±17.5秒 ≈ ±0.29分钟 function getRandomPauseTime() { return Math.round(pause_base_time + (Math.random() * 2 - 1) * pause_variance); } var search_words = []; //搜索词 var appkey = "";//从https://www.gmya.net/api 网站申请的热门词接口APIKEY var Hot_words_apis = "https://api.gmya.net/Api/";// 故梦热门词API接口网站 //默认搜索词,热门搜索词请求失败时使用(建议保持 22 个以上,可自行替换) var default_search_words = [ "今天空气质量怎么样", "附近菜市场在哪里", "最近好看的综艺节目", "肩膀酸痛怎么按摩", "可乐鸡翅怎么做", "电脑连不上网怎么办", "适合孩子看的动画片", "地铁末班车是几点", "痛风不能吃哪些食物", "法语入门难不难", "卫生间异味怎么去除", "二手电动车值得买吗", "小孩积食怎么调理", "烤箱烤鸡翅温度和时间", "跳绳减肥每天跳多少", "美元汇率今天多少", "台球基本规则", "养乌龟水深多少合适", "世界未解之谜", "PPT模板去哪里下载", "仙人掌多久浇一次水", "今年流行什么鞋子", "充电器一直插着好不好", "冬天手脚冰凉怎么办" ] //{weibohot}微博热搜榜//{douyinhot}抖音热搜榜/{zhihuhot}知乎热搜榜/{baiduhot}百度热搜榜/{toutiaohot}今日头条热搜榜/ var keywords_source = ['WeiBoHot', 'TouTiaoHot', 'DouYinHot', 'BaiduHot']; var random_keywords_source = keywords_source[Math.floor(Math.random() * keywords_source.length)]; var current_source_index = 0; // 当前搜索词来源的索引 /** * 尝试从多个搜索词来源获取搜索词,如果所有来源都失败,则返回默认搜索词。 * @returns {Promise} 返回搜索到的name属性值列表或默认搜索词列表 */ async function douyinhot_dic() { while (current_source_index < keywords_source.length) { const source = keywords_source[current_source_index]; // 获取当前搜索词来源 let url; //根据 appkey 是否为空来决定如何构建 URL地址,如果appkey为空,则直接请求接口地址 if (appkey) { url = Hot_words_apis + source + "?format=json&appkey=" + appkey;//有appkey则添加appkey参数 } else { url = Hot_words_apis + source;//无appkey则直接请求接口地址 } try { const response = await fetch(url); // 发起网络请求 if (!response.ok) { throw new Error('HTTP error! status: ' + response.status); // 如果响应状态不是OK,则抛出错误 } const data = await response.json(); // 解析响应内容为JSON if (data.data.some(item => item)) { // 如果数据中存在有效项 // 提取每个元素的title属性值 const names = data.data.map(item => item.title); return names; // 返回搜索到的title属性值列表 } } catch (error) { // 当前来源请求失败,记录错误并尝试下一个来源 console.error('搜索词来源请求失败:', error); } // 尝试下一个搜索词来源 current_source_index++; } // 所有搜索词来源都已尝试且失败 console.error('所有搜索词来源请求失败'); return default_search_words; // 返回默认搜索词列表 } // 执行搜索 douyinhot_dic() .then(names => { // console.log(names[0]); search_words = names; exec() }) .catch(error => { console.error(error); }); // 定义菜单命令:开始 let menu1 = GM_registerMenuCommand('开始', function () { GM_setValue('Cnt', 0); // 将计数器重置为0 location.href = "https://www.bing.com/?br_msg=Please-Wait"; // 跳转到Bing首页 }, 'o'); // 定义菜单命令:停止 let menu2 = GM_registerMenuCommand('停止', function () { GM_setValue('Cnt', max_rewards + 10); // 将计数器设置为超过最大搜索次数,以停止搜索 }, 'o'); // 自动将字符串中的字符进行替换 function AutoStrTrans(st) { let yStr = st; // 原字符串 let rStr = ""; // 插入的混淆字符,可以自定义自己的混淆字符串 let zStr = ""; // 结果字符串 let prePo = 0; for (let i = 0; i < yStr.length;) { let step = parseInt(Math.random() * 5) + 1; // 随机生成步长 if (i > 0) { zStr = zStr + yStr.substr(prePo, i - prePo) + rStr; // 将插入字符插入到相应位置 prePo = i; } i = i + step; } if (prePo < yStr.length) { zStr = zStr + yStr.substr(prePo, yStr.length - prePo); // 将剩余部分添加到结果字符串中 } return zStr; } // 生成指定长度的包含大写字母、小写字母和数字的随机字符串 function generateRandomString(length) { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; let result = ''; const charactersLength = characters.length; for (let i = 0; i < length; i++) { // 从字符集中随机选择字符,并拼接到结果字符串中 result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } function exec() { // 相邻两次搜索的随机间隔(45秒 ~ 65秒) let randomDelay = Math.floor(Math.random() * (search_delay_max - search_delay_min)) + search_delay_min; let randomString = generateRandomString(4); //生成4个长度的随机字符串 let randomCvid = generateRandomString(32); //生成32位长度的cvid 'use strict'; // 检查计数器的值,若为空则设置为超过最大搜索次数 if (GM_getValue('Cnt') == null) { GM_setValue('Cnt', max_rewards + 10); } // 获取当前搜索次数 let currentSearchCount = GM_getValue('Cnt'); // 根据计数器的值选择搜索引擎 if (currentSearchCount <= max_rewards / 2) { let tt = document.getElementsByTagName("title")[0]; tt.innerHTML = "[" + currentSearchCount + " / " + max_rewards + "] " + tt.innerHTML; // 在标题中显示当前搜索次数 smoothScrollToBottom(); // 添加执行滚动页面到底部的操作 GM_setValue('Cnt', currentSearchCount + 1); // 将计数器加1 setTimeout(function () { let nowtxt = search_words[currentSearchCount]; // 获取当前搜索词 nowtxt = AutoStrTrans(nowtxt); // 对搜索词进行替换 // 检查是否需要暂停 if ((currentSearchCount + 1) % 5 === 0) { setTimeout(function () { location.href = "https://www.bing.com/search?q=" + encodeURI(nowtxt) + "&form=" + randomString + "&cvid=" + randomCvid; // 在Bing搜索引擎中搜索 }, getRandomPauseTime()); // 停顿时间随机(约4分25秒 ~ 5分钟) } else { location.href = "https://www.bing.com/search?q=" + encodeURI(nowtxt) + "&form=" + randomString + "&cvid=" + randomCvid; // 在Bing搜索引擎中搜索 } }, randomDelay); } else if (currentSearchCount > max_rewards / 2 && currentSearchCount < max_rewards) { let tt = document.getElementsByTagName("title")[0]; tt.innerHTML = "[" + currentSearchCount + " / " + max_rewards + "] " + tt.innerHTML; // 在标题中显示当前搜索次数 smoothScrollToBottom(); // 添加执行滚动页面到底部的操作 GM_setValue('Cnt', currentSearchCount + 1); // 将计数器加1 setTimeout(function () { let nowtxt = search_words[currentSearchCount]; // 获取当前搜索词 nowtxt = AutoStrTrans(nowtxt); // 对搜索词进行替换 // 检查是否需要暂停 if ((currentSearchCount + 1) % 5 === 0) { setTimeout(function () { location.href = "https://cn.bing.com/search?q=" + encodeURI(nowtxt) + "&form=" + randomString + "&cvid=" + randomCvid; // 在Bing搜索引擎中搜索 }, getRandomPauseTime()); // 停顿时间随机(约4分25秒 ~ 5分钟) } else { location.href = "https://cn.bing.com/search?q=" + encodeURI(nowtxt) + "&form=" + randomString + "&cvid=" + randomCvid; // 在Bing搜索引擎中搜索 } }, randomDelay); } // 实现平滑滚动到页面底部的函数 function smoothScrollToBottom() { document.documentElement.scrollIntoView({ behavior: 'smooth', block: 'end' }); } }