Greasy Fork

必应Rewards每日任务

必应Rewards每日搜索任务自动完成工具

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

// ==UserScript==
// @name         必应Rewards每日任务
// @version      V1.0.1
// @description  必应Rewards每日搜索任务自动完成工具
// @author       怀沙2049
// @match        https://www.bing.com/*
// @match        https://cn.bing.com/*
// @license      GNU GPLv3
// @icon         https://www.bing.com/favicon.ico
// @run-at document-end
// @grant        GM_registerMenuCommand
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @namespace https://greasyfork.org/users/1029902  原作者地址
// ==/UserScript==

var max_rewards = 30; /*每次重复执行的次数*/

// 定义菜单命令1:开始
let menu1 = GM_registerMenuCommand('开始', function () {
    GM_setValue('Cnt', 0); // 将计数器重置为0
    location.href = "https://www.bing.com/?br_msg=Please-Wait"; // 跳转到Bing首页
  }, 'o');
  
  // 定义菜单命令2:停止
  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() * 6) + 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() {
    'use strict';
  
    // 检查计数器的值,若为空则设置为超过最大搜索次数
    if (GM_getValue('Cnt') == null) {
      GM_setValue('Cnt', max_rewards + 10);
    }
  
    // 根据计数器的值选择搜索引擎
    if (GM_getValue('Cnt') <= max_rewards / 2) {
      let tt = document.getElementsByTagName("title")[0];
      tt.innerHTML = "[" + GM_getValue('Cnt') + " / " + max_rewards + "] " + tt.innerHTML; // 在标题中显示当前搜索次数
  
      setTimeout(function() {
        GM_setValue('Cnt', GM_getValue('Cnt') + 1); // 将计数器加1
        let nowtxt = search_dic[GM_getValue('Cnt')]; // 获取当前搜索词
        nowtxt = AutoStrTrans(nowtxt); // 对搜索词进行替换
        location.href = "https://www.bing.com/search?q=" + encodeURI(nowtxt); // 在Bing搜索引擎中搜索
      }, 3000);
    }
  
    if (GM_getValue('Cnt') > max_rewards / 2 && GM_getValue('Cnt') < max_rewards) {
      let tt = document.getElementsByTagName("title")[0];
      tt.innerHTML = "[" + GM_getValue('Cnt') + " / " + max_rewards + "] " + tt.innerHTML; // 在标题中显示当前搜索次数
  
      setTimeout(function() {
        GM_setValue('Cnt', GM_getValue('Cnt') + 1); // 将计数器加1
        let nowtxt = search_dic[GM_getValue('Cnt')]; // 获取当前搜索词
        nowtxt = AutoStrTrans(nowtxt); // 对搜索词进行替换
        location.href = "https://cn.bing.com/search?q=" + encodeURI(nowtxt); // 在Bing搜索引擎中搜索
      }, 3000);
    }
  })();