自动搜索微软积分-国内外通用

自用微软积分搜索脚本,国际版与国内版通用

目前为 2023-03-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         自动搜索微软积分-国内外通用
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  自用微软积分搜索脚本,国际版与国内版通用
// @author       青鸟丹心
// @match        https://www.bing.com/*
// @grant        GM_xmlhttpRequest
// @grant        GM_openInTab
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// ==/UserScript==

const searchUrl = 'https://www.bing.com/search';
const isDesktop = window.matchMedia("(min-width: 768px)").matches; // 检查是否为电脑端

// Check if the current URL is bing.com
if (window.location.hostname === 'www.bing.com') {
    // If it is, execute the random search every 2000 milliseconds (2 seconds)
    const loopCount = isDesktop ? 50 : 30; // 根据设备类型设置循环次数
    let count = 0; // 计数器,用于记录循环次数
    const intervalId = setInterval(function() {
        // Generate a random search query
        const search = generateRandomSearch();

        // Enter the search query into the Bing search bar
        document.getElementById("sb_form_q").value = search;
        // Submit the search
        document.getElementById("sb_form").submit();

        // Increment the counter and check if we've reached the loop count
        count++;
        if (count === loopCount) {
            clearInterval(intervalId); // 停止循环
        }
    }, 2000);
}

function generateRandomSearch() {
    let search = '';
    // Generate a random string of 5 characters
    for (let i = 0; i < 5; i++) {
        // Generate a random number between 0 and 1
        const r = Math.random();
        // If the number is less than 0.5, add a random letter
        if (r < 0.5) {
            search += String.fromCharCode(Math.floor(Math.random() * 26) + 65);
        }
        // Otherwise, add a random number (0-9) to the search string
        else {
            search += Math.floor(Math.random() * 10);
        }
    }
    return search;
}

QingJ © 2025

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