// ==UserScript==
// @name Bing 必应积分自动脚本(Bing Rewards Script)
// @version 1.0.0
// @description 使用Edge搜索,生成高度随机且丰富的智能搜索词,循环搜索直到达到指定次数。优化UI,包含倒计时。本脚本修改自 yclown 的原始项目。
// @author BABAlala (原作者 yclown, 修改自其项目 https://github.com/yclown/myTamperMokey)
// @match https://cn.bing.com/search?*
// @match https://www.bing.com/search?*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @require https://code.jquery.com/jquery-3.1.1.min.js
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @license GPL
// @namespace https://greasyfork.org/users/1413398
// ==/UserScript==
(function() {
'use strict';
// 日期格式化
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"H+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
};
// 默认配置
const DEFAULT_CONFIG = {
max_pc: 40,
max_ph: 30,
min_interval: 60,
max_interval: 120
};
// 添加美化样式
GM_addStyle(`
#reward_tool {
position: fixed; right: 20px; top: 150px; background: linear-gradient(135deg, #ffffff, #f0f4f8);
padding: 20px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); width: 220px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; border: 1px solid #e0e4e8;
}
#reward_tool a {
display: block; margin: 8px 0; padding: 6px 10px; color: #ffffff; background: #0078d4;
border-radius: 6px; text-decoration: none; text-align: center; transition: background 0.3s;
}
#reward_tool a:hover { background: #005bb5; }
#reward_tool p { margin: 10px 0; color: #2c3e50; font-size: 14px; }
#reward_tool .count { font-weight: bold; color: #e74c3c; }
#reward_tool .label { color: #7f8c8d; }
#reward_tool #reward_info { font-style: italic; color: #27ae60; }
#reward_tool #countdown { color: #e67e22; font-weight: bold; font-size: 16px; }
#reward_tool hr { border: 0; border-top: 1px solid #dfe6e9; margin: 10px 0; }
`);
// 初始化界面
const tab = document.querySelector('body');
const countInfo = GetConfig();
const div = `
<div id="reward_tool">
<a id="reward_finish">结束脚本</a>
<a id="reward_clean">重置搜索</a>
<hr>
<p><span class="label">电脑:</span> <span class="count" id="pc_count">${countInfo.pc_count}</span> / ${DEFAULT_CONFIG.max_pc}</p>
<p><span class="label">手机:</span> <span class="count" id="ph_count">${countInfo.ph_count}</span> / ${DEFAULT_CONFIG.max_ph}</p>
<p id="reward_info"></p>
<hr>
<p>下次搜索: <span id="countdown">--</span></p>
</div>`;
tab.insertAdjacentHTML('beforeend', div);
// 事件绑定
$("body").on("click", "#reward_clean", CleanCount);
$("body").on("click", "#reward_finish", Finish);
// 主循环
let timer = null;
StartSearch();
function StartSearch() {
const config = GetConfig();
if (config.pc_count >= DEFAULT_CONFIG.max_pc && config.ph_count >= DEFAULT_CONFIG.max_ph) {
ShowInfo(config);
return;
}
const interval = GetRandomInterval();
let remainingTime = interval / 1000;
UpdateCountdown(remainingTime);
timer = setInterval(() => {
remainingTime--;
UpdateCountdown(remainingTime);
if (remainingTime <= 0) {
clearInterval(timer);
PerformSearch();
StartSearch();
}
}, 1000);
}
function PerformSearch() {
const config = GetConfig();
if ((!IsPhone() && config.pc_count >= DEFAULT_CONFIG.max_pc) || (IsPhone() && config.ph_count >= DEFAULT_CONFIG.max_ph)) return;
try {
const searchInput = document.getElementById("sb_form_q");
if (!searchInput) throw new Error("搜索框未找到");
searchInput.value = GetRandomSearchTerm();
if (IsPhone()) config.ph_count++;
else config.pc_count++;
GM_setValue("bing_reward", JSON.stringify(config));
ShowInfo(config);
const searchButton = document.getElementById("sb_form_go");
if (!searchButton) throw new Error("搜索按钮未找到");
searchButton.click();
} catch (error) {
console.error("搜索出错:", error);
setTimeout(StartSearch, 5000);
}
}
// 手机检测
function IsPhone() {
const userAgent = navigator.userAgent;
const isMobileUA = /mobile/i.test(userAgent);
const isSmallScreen = window.innerWidth < 768;
return isMobileUA || isSmallScreen;
}
// 获取配置
function GetConfig() {
let config = GM_getValue("bing_reward");
const today = new Date().Format("yyyy-MM-dd");
if (!config || JSON.parse(config).date !== today) {
config = { date: today, pc_count: 0, ph_count: 0 };
} else {
config = JSON.parse(config);
}
return config;
}
// 显示信息
function ShowInfo(config) {
document.getElementById("pc_count").textContent = config.pc_count;
document.getElementById("ph_count").textContent = config.ph_count;
let status = '';
if (config.pc_count < DEFAULT_CONFIG.max_pc) status += '电脑未完成 ';
if (config.ph_count < DEFAULT_CONFIG.max_ph) status += '手机未完成';
if (!status) status = '今日已完成';
document.getElementById("reward_info").textContent = status;
}
// 更新倒计时
function UpdateCountdown(seconds) {
document.getElementById("countdown").textContent = seconds > 0 ? `${Math.floor(seconds)}秒` : '正在搜索...';
}
// 重置计数
function CleanCount() {
const today = new Date().Format("yyyy-MM-dd");
GM_setValue("bing_reward", JSON.stringify({
date: today,
pc_count: 0,
ph_count: 0
}));
alert("计数已重置");
location.reload();
}
// 结束脚本
function Finish() {
const today = new Date().Format("yyyy-MM-dd");
GM_setValue("bing_reward", JSON.stringify({
date: today,
pc_count: DEFAULT_CONFIG.max_pc,
ph_count: DEFAULT_CONFIG.max_ph
}));
clearInterval(timer);
alert("脚本已结束");
}
// 改进:生成高度随机且丰富的搜索词
function GetRandomSearchTerm() {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
const day = now.getDate();
const hour = now.getHours();
// 扩展词库
const questions = [
'如何快速', '什么是最好的', '哪里可以找到', '怎样才能学会', '为什么需要', '什么时候适合', '谁能推荐',
'有没有人知道', '如何避免', '哪个更适合'
];
const actions = [
'学习', '制作', '找到', '提高', '优化', '下载', '购买', '预订', '分析', '比较', '设计', '分享', '探索', '解决', '体验'
];
const topics = [
'人工智能技术', '区块链应用', '云计算平台', '大数据分析', '编程语言入门', '网络安全防护', '天气预报查询', '电影票房排行',
'健康饮食计划', '旅游景点推荐', '本地美食指南', '体育赛事直播', '电子竞技比赛', '音乐节门票', '时尚穿搭灵感', '在线教育资源',
'汽车保养技巧', '摄影后期教程', '历史人物故事', '科学实验方法', '理财投资策略', '法律咨询服务', '游戏内购攻略', 'DIY手工项目',
'宠物训练技巧', '家居装修风格', '职业技能提升', '心理减压方法', '环保节能技术', '传统文化艺术', '健身运动计划', '烹饪技巧分享'
];
const qualifiers = [
`${year}年`, `${month}月`, `${day}日`, '最新版', '免费的', '简单的', '高效的', '热门的', '实用的', '专业的', '本地的', '国际版',
'高级版', '基础版', '实时', '经典', '创新', '便捷', '详细', '独家'
];
const specifics = [
'教程视频', '实用工具', '软件推荐', '技巧分享', '行业趋势', '排行榜单', '详细攻略', '家常菜谱', '装备选择', '电子书籍',
'在线课程', '活动安排', '政策解读', '案例研究', '数据分析', '比赛日程', '产品评测', '品牌对比', '用户评论', '价格信息',
'最佳地点', '时间安排', '操作方法', '资源下载', '经验总结', '隐藏秘诀', '完整指南', '任务清单', '性能测评', '专家推荐',
'常见问题解答', '入门介绍', '高级技巧'
];
const extras = [
'适合新手', '性价比最高', '最受欢迎的选择', '包含详细步骤', '支持在线使用', '适合离线学习', '专家亲自指导', '用户真实评价',
'解决常见疑问', '最新更新版本', '适合团队使用', '个人定制版', '快速上手指南', '节省时间的方法', '无需额外费用'
];
const connectors = ['和', '与', '还是', '或者', '对比', '加上', '包括', '基于', '关于', '针对'];
// 随机模式(增加复杂度和随机性)
const mode = Math.floor(Math.random() * 8);
switch (mode) {
case 0: // 超复杂问句
return `${questions[Math.floor(Math.random() * questions.length)]} ${actions[Math.floor(Math.random() * actions.length)]} ${qualifiers[Math.floor(Math.random() * qualifiers.length)]} 的 ${topics[Math.floor(Math.random() * topics.length)]} ${specifics[Math.floor(Math.random() * specifics.length)]} ${extras[Math.floor(Math.random() * extras.length)]}`;
case 1: // 双主题组合
return `${qualifiers[Math.floor(Math.random() * qualifiers.length)]} 的 ${topics[Math.floor(Math.random() * topics.length)]} ${connectors[Math.floor(Math.random() * connectors.length)]} ${topics[Math.floor(Math.random() * topics.length)]} 的 ${specifics[Math.floor(Math.random() * specifics.length)]}`;
case 2: // 时效性复杂查询
return `${questions[Math.floor(Math.random() * questions.length)]} ${month}月${day}日 ${actions[Math.floor(Math.random() * actions.length)]} ${topics[Math.floor(Math.random() * topics.length)]} 的 ${specifics[Math.floor(Math.random() * specifics.length)]} ${extras[Math.floor(Math.random() * extras.length)]}`;
case 3: // 动作+多修饰
return `${actions[Math.floor(Math.random() * actions.length)]} ${qualifiers[Math.floor(Math.random() * qualifiers.length)]} ${topics[Math.floor(Math.random() * topics.length)]} 的 ${specifics[Math.floor(Math.random() * specifics.length)]} ${connectors[Math.floor(Math.random() * connectors.length)]} ${qualifiers[Math.floor(Math.random() * qualifiers.length)]} 版本`;
case 4: // 随机拼接
return `${topics[Math.floor(Math.random() * topics.length)]} ${specifics[Math.floor(Math.random() * specifics.length)]} ${qualifiers[Math.floor(Math.random() * qualifiers.length)]} ${extras[Math.floor(Math.random() * extras.length)]}`;
case 5: // 超长详细查询
return `${questions[Math.floor(Math.random() * questions.length)]} 在 ${year}年${month}月 ${actions[Math.floor(Math.random() * actions.length)]} ${qualifiers[Math.floor(Math.random() * qualifiers.length)]} 的 ${topics[Math.floor(Math.random() * topics.length)]} ${specifics[Math.floor(Math.random() * specifics.length)]} ${extras[Math.floor(Math.random() * extras.length)]}`;
case 6: // 对比模式
return `${qualifiers[Math.floor(Math.random() * qualifiers.length)]} 的 ${topics[Math.floor(Math.random() * topics.length)]} ${specifics[Math.floor(Math.random() * specifics.length)]} ${connectors[Math.floor(Math.random() * connectors.length)]} ${topics[Math.floor(Math.random() * topics.length)]} 的区别`;
case 7: // 短而随机
return `${actions[Math.floor(Math.random() * actions.length)]} ${topics[Math.floor(Math.random() * topics.length)]} ${qualifiers[Math.floor(Math.random() * qualifiers.length)]}`;
default:
return `${topics[Math.floor(Math.random() * topics.length)]} 最新 ${specifics[Math.floor(Math.random() * specifics.length)]}`;
}
}
// 随机时间间隔
function GetRandomInterval() {
const min = DEFAULT_CONFIG.min_interval * 1000;
const max = DEFAULT_CONFIG.max_interval * 1000;
return Math.floor(Math.random() * (max - min + 1)) + min;
}
})();