Bing Rewards

PC/移动端模拟用户操作,获取热搜词进行搜索,搜索后返回继续,持续这个过程,需要手动停止。每四个搜索后间隔15分钟(连续获取积分被风控)。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bing Rewards
// @description  PC/移动端模拟用户操作,获取热搜词进行搜索,搜索后返回继续,持续这个过程,需要手动停止。每四个搜索后间隔15分钟(连续获取积分被风控)。
// @version      1.0.15
// @match        https://www.bing.com/*
// @match        https://cn.bing.com/*
// @icon         https://www.bing.com/favicon.ico
// @run-at       document-idle
// @grant        GM_xmlhttpRequest
// @connect      *
// @namespace    https://greasyfork.org/users/1363215
// ==/UserScript==

(function () {
    'use strict';
    let timer = null
    const localStorageKeys = {
        current: 'BING_CURRENT_SEARCH',
        searchWords: 'BING_SEARCH_WORDS',
        isActive: 'BING_SEARCH_ACTIVE',
        wordsDate: 'BING_WORDS_DATE',
    }
    const hotType = ['weibo', 'xiaohongshu', 'bilibili', 'douyin', 'toutiao', 'baidu', 'hupu', 'qq']
    const hotTypeLen = hotType.length

    const isToday = (date) => {
        const d = new Date(date);
        const today = new Date();
        return d.toDateString() === today.toDateString();
    };


    const formatDate = (date) => {
        const YYYY = date.getFullYear();
        const MM = (date.getMonth() + 1).toString().padStart(2, '0');
        const DD = date.getDate().toString().padStart(2, '0');
        return `${YYYY}-${MM}-${DD}`;
    };

    const formatTime = (date) => {
        const h = date.getHours().toString().padStart(2, '0');
        const m = date.getMinutes().toString().padStart(2, '0');
        const s = date.getSeconds().toString().padStart(2, '0');
        return `${h}:${m}:${s}`;
    };

    const queryHotWords = () => {
        return new Promise((resolve, reject) => {
            const randomType = Math.floor(Math.random() * hotTypeLen)
            GM_xmlhttpRequest({
                method: 'GET',
                url: 'https://hot.baiwumm.com/api/' + hotType[randomType],
                headers: {
                    "Content-Type": "application/json",
                    "referer": "https://hot.baiwumm.com/",
                    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36",
                },
                onload: function (response) {
                    console.log(response.responseText);
                    const { code, data } = JSON.parse(response.responseText)
                    if (code === 200) {
                        localStorage.setItem(localStorageKeys.wordsDate, formatDate(new Date()))
                        localStorage.setItem(localStorageKeys.current, '0')
                        localStorage.setItem(localStorageKeys.searchWords, JSON.stringify(data))
                        resolve()
                    }
                },
                onerror: function (e) {
                    console.log(e)
                    reject()
                }
            });
        })
    }

    let current = Number(localStorage.getItem(localStorageKeys.current) || '0')

    function doSearch() {
        const words = JSON.parse(localStorage.getItem(localStorageKeys.searchWords) || '[]')
        const word = words[current]
        const wordsDate = localStorage.getItem(localStorageKeys.wordsDate) || '2026-01-01'
        if (word && isToday(wordsDate)) {
            document.getElementById('sb_form_q')?.click()
            setTimeout(() => {
                document.getElementById('sb_form_q').value = word.title;
                setTimeout(() => {
                    // 文本有时候会丢失,多设置一次
                    document.getElementById('sb_form_q').value = word.title;
                    document.getElementById('sb_form_go').click()
                    localStorage.setItem(localStorageKeys.current, current + 1)
                }, (1 + Math.ceil(Math.random() * 3)) * 1000)
            }, (1 + Math.ceil(Math.random() * 3)) * 1000)
        } else {
            queryHotWords().then(() => { current = 0; setTimeout(doSearch, 1000) })
        }
    }


    function startAction() {
        // h5 页面会有一次奇怪的 pathname 变更
        if (location.pathname === '/') {
            if (current === 0) {
                queryHotWords().then(() => { timer = setTimeout(doSearch, 1000) })
            } else {
                timer = setTimeout(doSearch, 1500)
            }
        }

        if (location.pathname === '/search') {
            if (location.search.includes('form=BHPPHT') || location.search.includes('form=QBLH')) {
                // 每四个搜索后,间隔15-20分钟
                const delay = current % 4 === 0 ? (15 + Math.ceil(Math.random() * 5)) * 60 * 1000 : (10 + Math.ceil(Math.random() * 5)) * 1000
                const $startBtn = document.getElementById('startBtn')
                if ($startBtn) {
                    $startBtn.textContent = 'next:' + formatTime(new Date(delay + new Date().getTime()))
                }
                timer = setTimeout(() => {
                    const $logo = document.getElementsByClassName('b_logoArea')[0]
                    if ($logo) {
                        location.replace($logo.getAttribute('href') || '/')
                    } else {
                        location.replace('/')
                    }
                }, delay)
            }
        }
    }

    function toggleJifen() {
        const isActive = localStorage.getItem(localStorageKeys.isActive)
        const $startBtn = document.getElementById('startBtn')
        if (isActive) {
            $startBtn.textContent = '开始'
            localStorage.removeItem(localStorageKeys.isActive)
            clearTimeout(timer)
        } else {
            $startBtn.textContent = '停止'
            localStorage.setItem(localStorageKeys.isActive, '1')
            startAction()
        }
    }

    if (location.pathname === '/' || location.pathname === '/search') {
        const isActive = localStorage.getItem(localStorageKeys.isActive)
        const actionBtn = document.createElement('button')
        actionBtn.setAttribute('id', 'startBtn')
        actionBtn.textContent = isActive ? '停止' : '开始'
        actionBtn.onclick = toggleJifen
        const nameId = location.pathname === '/' ? 'id_n' : 'id_h'
        const $Name = document.getElementById(nameId)
        $Name.parentNode.insertBefore(actionBtn, $Name)
        if (isActive) {
            startAction()
        }
    }
})();