Greasy Fork 支持简体中文。

MicrosoftScript

自动

  1. // ==UserScript==
  2. // @name MicrosoftScript
  3. // @namespace 3hex
  4. // @version 0.1.1
  5. // @description 自动
  6. // @author 3hex
  7. // @match https://www.bing.com/*
  8. // @match https://cn.bing.com/*
  9. // @icon https://az15297.vo.msecnd.net/images/rewards/membercenter/missions/Animated-Icons/bing_icon.svg
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. var currentURL = window.location.href;
  18. var domain = new URL(currentURL).hostname;
  19.  
  20. function getMobileViewport(width, height) {
  21. return {
  22. width: width,
  23. height: height,
  24. deviceScaleFactor: 1,
  25. mobile: true
  26. };
  27. }
  28.  
  29. var num = 0;
  30. var mode = 0 // 0:PC 1:mobile
  31.  
  32. console.log("[info] successful match");
  33.  
  34. const timestamp2 = new Date().getTime(); // 获取当前时间戳
  35. const timestampString = timestamp2.toString();
  36. const randomIndex = Math.floor(Math.random() * (timestampString.length - 1)) + 1;
  37. const prefix = parseInt(timestampString.substring(0, randomIndex));
  38. const postfix = Math.floor(Math.random() * 200) + 1; // 生成随机数在1到200之间
  39. const timestamp = prefix.toString() + "+" + postfix.toString() + "="; // 修改成字符串拼接形式
  40.  
  41. console.log("[info] timestamp:"+timestamp); // 输出当前时间戳
  42.  
  43. const div = document.createElement('div');
  44. const img = document.createElement('img');
  45. const span = document.createElement('span')
  46.  
  47. div.appendChild(img);
  48. div.appendChild(span);
  49.  
  50. img.src = 'https://az15297.vo.msecnd.net/images/rewards/membercenter/missions/Animated-Icons/bing_icon.svg'; // 设置 img 的 src 属性
  51.  
  52. img.id = "mrs_img_auto";
  53. div.style.position = 'fixed'; // 设置定位方式为固定定位
  54. div.style.top = '15%'; // 设置 img 的上边缘距离屏幕顶部的距离为 0
  55. div.style.left = '3%'; // 设置 img 的左边缘距离屏幕左侧的距离为 0
  56.  
  57. span.textContent = "0";
  58. span.style.color = "red";
  59. span.style.fontWeight = 'bold';
  60. span.style.display = 'flex';
  61. span.style.alignItems = 'center';
  62. span.style.justifyContent = 'center';
  63.  
  64. num = parseInt(localStorage.getItem('mrs_count_num'), 10);
  65. mode = parseInt(localStorage.getItem('mrs_count_mode'), 10);
  66. if(!isNaN(num) && num != 0) {
  67. span.textContent = "" + num;
  68. console.log("[info] count:" + num);
  69. num = num - 1;
  70. localStorage.setItem('mrs_count_num', num);
  71.  
  72. setTimeout(function() {
  73. // 生成随机数
  74. var textarea = document.getElementById('sb_form_q');
  75. const randomNumber1 = Math.floor(Math.random() * 100) + 1;
  76. const randomNumber2 = Math.floor(Math.random() * 100) + 1;
  77. const result = randomNumber1.tostring * randomNumber2;
  78.  
  79. // 将随机数文本设置为textarea的值
  80. textarea.value = randomNumber1.toString() + " + " + randomNumber2.toString() + " = "
  81. var searchButton = document.getElementById('sb_form_go');
  82.  
  83. // 触发点击事件
  84. searchButton.click();
  85. }, Math.floor(Math.random() * (10000 - 5000 + 1)) + 5000); // 随机延迟5到10秒
  86. }
  87.  
  88. div.addEventListener('click', function() { // 添加点击事件监听器
  89. const n = window.prompt('Please enter a number(Number of searches):');
  90. num = parseInt(n, 10);
  91. if(!isNaN(num) && num != 0) {
  92. span.textContent = "" + num;
  93. console.log("[info] first count:" + num);
  94. num = num - 1;
  95.  
  96. localStorage.setItem('mrs_count_num', num);
  97.  
  98. setTimeout(function() {
  99. var textarea = document.getElementById('sb_form_q');
  100.  
  101. // 生成随机数
  102. const randomNumber1 = Math.floor(Math.random() * 100) + 1;
  103. const randomNumber2 = Math.floor(Math.random() * 100) + 1;
  104. const result = randomNumber1 * randomNumber2;
  105.  
  106. // 将随机数文本设置为textarea的值
  107. textarea.value = randomNumber1.toString() + " + " + randomNumber2.toString() + " = "
  108. var searchButton = document.getElementById('sb_form_go');
  109.  
  110. // 触发点击事件
  111. searchButton.click();
  112. }, Math.floor(Math.random() * (7000 - 5000 + 1))); // 随机延迟5到10秒
  113.  
  114. } else {
  115. console.log("[info] cancel");
  116. }
  117. });
  118. document.getElementById('b_content').appendChild(div);
  119.  
  120. // 监听键盘按键事件
  121. document.addEventListener('keydown', function(event) {
  122. if (event.ctrlKey && event.altKey && event.key === 'l') {
  123. if (confirm("Whether you want to stop automatic search? ")) {
  124. console.log("[info] stop");
  125. num = 0;
  126. localStorage.setItem('mrs_count_num', 0);;
  127. } else {
  128. console.log("[info] continue :) ");
  129. }
  130. }
  131. });
  132.  
  133. })();
  134.