微软Bing 必应积分自动脚本(Microsoft Bing Rewards Script)

使用Edge搜索,生成高度随机且丰富的智能搜索词,循环搜索直到达到指定次数。优化UI,包含倒计时。本脚本修改自 yclown 的原始项目。

目前為 2025-04-09 提交的版本,檢視 最新版本

// ==UserScript==
// @name         微软Bing 必应积分自动脚本(Microsoft Bing Rewards Script)
// @version      1.0.3
// @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-3.0
// @namespace    https://gf.qytechs.cn/users/1413398
// ==/UserScript==

(function() {
    'use strict';

    // 默认配置
    const DEFAULT_CONFIG = {
        max_pc: 40,
        max_ph: 30,
        min_interval: 60,
        max_interval: 120
    };

    // 添加美化样式
    GM_addStyle(`
        #reward_tool {
            position: fixed; right: 10px; top: 100px; background: #fff; padding: 15px; border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 200px; font-family: sans-serif; z-index: 9999;
        }
        #reward_tool a {
            display: block; margin: 5px 0; padding: 5px; color: #fff; background: #0078d4; border-radius: 4px; text-align: center;
        }
        #reward_tool a:hover { background: #005bb5; }
        #reward_tool p { margin: 5px 0; color: #333; font-size: 12px; }
        #reward_tool .count { font-weight: bold; color: #e74c3c; }
        #reward_tool #reward_info { color: #27ae60; }
        #reward_tool #countdown { color: #e67e22; font-weight: bold; }
    `);

    // 初始化界面
    const countInfo = GetConfig();
    document.body.insertAdjacentHTML('beforeend', `
        <div id="reward_tool">
            <a id="reward_finish">结束脚本</a>
            <a id="reward_clean">重置搜索</a>
            <p>电脑: <span class="count" id="pc_count">${countInfo.pc_count}</span> / ${DEFAULT_CONFIG.max_pc}</p>
            <p>手机: <span class="count" id="ph_count">${countInfo.ph_count}</span> / ${DEFAULT_CONFIG.max_ph}</p>
            <p id="reward_info"></p>
            <p>下次搜索: <span id="countdown">--</span></p>
        </div>`);

    // 事件绑定
    $("body").on("click", "#reward_clean", CleanCount);
    $("body").on("click", "#reward_finish", Finish);

    // 主循环
    let timer = null;
    StartSearch();

    function StartSearch() {
        const config = GetConfig();
        console.log("StartSearch: ", config, "IsPhone: ", IsPhone());
        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();
        console.log("PerformSearch: ", config);
        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") || document.querySelector("input[name='q']");
            const searchButton = document.getElementById("sb_form_go") || document.querySelector("button[type='submit']");
            console.log("Input: ", searchInput, "Button: ", searchButton);

            if (!searchInput) throw new Error("搜索框未找到");
            if (!searchButton) throw new Error("搜索按钮未找到");

            searchInput.value = GetRandomSearchTerm();
            if (IsPhone()) config.ph_count++; else config.pc_count++;
            GM_setValue("bing_reward", JSON.stringify(config));
            ShowInfo(config);
            searchButton.click();
        } catch (error) {
            console.error("搜索出错:", error);
            setTimeout(StartSearch, 5000); // 出错后5秒重试
        }
    }

    // 手机检测
    function IsPhone() {
        const userAgent = navigator.userAgent.toLowerCase();
        const isMobileUA = /mobile|android|iphone|ipad|touch/i.test(userAgent);
        const isSmallScreen = window.innerWidth < 768;
        return isMobileUA || isSmallScreen;
    }

    // 获取配置
    function GetConfig() {
        let config = GM_getValue("bing_reward");
        const today = new Date().toISOString().split("T")[0]; // 简化日期处理
        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;
        document.getElementById("reward_info").textContent = config.pc_count < DEFAULT_CONFIG.max_pc || config.ph_count < DEFAULT_CONFIG.max_ph ? '未完成' : '今日已完成';
    }

    // 更新倒计时
    function UpdateCountdown(seconds) {
        document.getElementById("countdown").textContent = seconds > 0 ? `${Math.floor(seconds)}秒` : '搜索中...';
    }

    // 重置计数
    function CleanCount() {
        const today = new Date().toISOString().split("T")[0];
        GM_setValue("bing_reward", JSON.stringify({ date: today, pc_count: 0, ph_count: 0 }));
        alert("计数已重置");
        location.reload();
    }

    // 结束脚本
    function Finish() {
        const today = new Date().toISOString().split("T")[0];
        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 topics = ['AI', '区块链', '云计算', '编程', '安全', '天气', '电影', '健康', '旅游', '美食'];
        const actions = ['学习', '制作', '找到', '优化', '下载'];
        const qualifiers = ['最新', '免费', '简单', '高效', new Date().getFullYear() + '年'];
        return `${actions[Math.floor(Math.random() * actions.length)]} ${qualifiers[Math.floor(Math.random() * qualifiers.length)]} ${topics[Math.floor(Math.random() * topics.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;
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址