Microsoft Reward Script

Get Microsoft Rewards through automatic search

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

  1. // ==UserScript==
  2. // @name Microsoft Reward Script
  3. // @namespace 3hex
  4. // @version 0.4
  5. // @description Get Microsoft Rewards through automatic search
  6. // @author 3hex
  7. // @match https://www.bing.com/*
  8. // @match https://cn.bing.com/*
  9. // @icon https://img1.imgtp.com/2023/05/16/SZZNGGT4.svg
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. function getMobileViewport(width, height) {
  18. return {
  19. width: width,
  20. height: height,
  21. deviceScaleFactor: 1,
  22. mobile: true
  23. };
  24. }
  25.  
  26. var num = 0;
  27. var mode = 0 // 0:PC 1:mobile
  28.  
  29. console.log("[info] successful match");
  30.  
  31. const timestamp = new Date().getTime(); // 获取当前时间戳
  32. console.log("[info] timestamp:"+timestamp); // 输出当前时间戳
  33.  
  34. const div = document.createElement('div');
  35. const img = document.createElement('img');
  36. const span = document.createElement('span')
  37.  
  38. div.appendChild(img);
  39. div.appendChild(span);
  40.  
  41. img.src = 'https://img1.imgtp.com/2023/05/16/SZZNGGT4.svg'; // 设置 img 的 src 属性
  42.  
  43. img.id = "mrs_img_auto";
  44. div.style.position = 'fixed'; // 设置定位方式为固定定位
  45. div.style.top = '15%'; // 设置 img 的上边缘距离屏幕顶部的距离为 0
  46. div.style.left = '3%'; // 设置 img 的左边缘距离屏幕左侧的距离为 0
  47.  
  48. span.textContent = "0";
  49. span.style.color = "red";
  50. span.style.fontWeight = 'bold';
  51. span.style.display = 'flex';
  52. span.style.alignItems = 'center';
  53. span.style.justifyContent = 'center';
  54.  
  55. num = parseInt(localStorage.getItem('mrs_count_num'), 10);
  56. mode = parseInt(localStorage.getItem('mrs_count_mode'), 10);
  57. if(!isNaN(num)&&num!=0)
  58. {
  59. span.textContent = ""+num;
  60. console.log("[info] count:"+num);
  61. num = num - 1;
  62. localStorage.setItem('mrs_count_num',num);
  63.  
  64. const url = "https://cn.bing.com/search?q="+timestamp; // 目标网页的地址
  65. window.open(url, "_self"); // 在当前页面中打开目标网页
  66. }
  67.  
  68. div.addEventListener('click', function() { // 添加点击事件监听器
  69. const n = window.prompt('Please enter a number(Number of searches):');
  70. num = parseInt(n, 10);
  71. if(!isNaN(num)&&num!=0) {
  72. span.textContent = ""+num;
  73. console.log("[info] first count:"+num);
  74. num = num - 1;
  75.  
  76. localStorage.setItem('mrs_count_num',num);;
  77.  
  78. const url = "https://cn.bing.com/search?q="+timestamp; // 目标网页的地址
  79. window.open(url, "_self"); // 在当前页面中打开目标网页
  80.  
  81. }else
  82. {
  83. console.log("[info] cancel");
  84. }
  85. });
  86.  
  87.  
  88. document.getElementById('b_content').appendChild(div);
  89.  
  90. })();
  91.