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

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

  1. // ==UserScript==
  2. // @name 自动搜索微软积分-国内外通用
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4
  5. // @description 自用微软积分搜索脚本,国际版与国内版通用
  6. // @author 青鸟丹心
  7. // @match https://*.bing.com/*
  8. // @grant GM_xmlhttpRequest
  9. // @grant GM_openInTab
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @grant GM_deleteValue
  13. // ==/UserScript==
  14.  
  15. const searchUrl = 'https://www.bing.com/search';
  16. const isDesktop = window.matchMedia("(min-width: 768px)").matches;
  17.  
  18. // Check if the current URL is bing.com or cn.bing.com
  19. if (window.location.hostname.endsWith('.bing.com')) {
  20. // If it is, execute the random search every 2000 milliseconds (2 seconds)
  21. const loopCount = isDesktop ? 50 : 30; // 根据设备类型设置循环次数
  22. let count = GM_getValue('searchCount', 0); // 从存储器中获取计数器初始值
  23. const intervalId = setInterval(function() {
  24. if (count >= loopCount) {
  25. clearInterval(intervalId); // 停止循环
  26. GM_deleteValue('searchCount'); // 删除计数器的值
  27. window.close(); // 关闭 Bing 页面
  28. return;
  29. }
  30. // Generate a random search query
  31. const search = generateRandomSearch();
  32.  
  33. // Enter the search query into the Bing search bar
  34. const searchBox = document.getElementById('sb_form_q');
  35. searchBox.value = search;
  36. searchBox.dispatchEvent(new Event('input')); // 触发输入框的输入事件,以便提交表单
  37.  
  38. // Submit the search
  39. const searchForm = document.getElementById('sb_form');
  40. searchForm.submit();
  41.  
  42. // Increment the counter and update the value in storage
  43. count++;
  44. GM_setValue('searchCount', count);
  45. }, 2000);
  46. }
  47.  
  48. function generateRandomSearch() {
  49. let search = '';
  50. // Generate a random string of 4 digits and 1 letter
  51. for (let i = 0; i < 4; i++) {
  52. search += Math.floor(Math.random() * 10);
  53. }
  54. search += String.fromCharCode(Math.floor(Math.random() * 26) + 65);
  55. return search;
  56. }

QingJ © 2025

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