Microsoft Reward Script

Get Microsoft Rewards through automatic search

Fra 16.05.2023. Se den seneste versjonen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Microsoft Reward Script
// @namespace    3hex
// @version      0.3
// @description  Get Microsoft Rewards through automatic search
// @author       3hex
// @match        https://www.bing.com/*
// @match        https://cn.bing.com/*
// @icon         https://az15297.vo.msecnd.net/images/rewards.svg
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function getMobileViewport(width, height) {
        return {
            width: width,
            height: height,
            deviceScaleFactor: 1,
            mobile: true
        };
    }

    var num = 0;
    var mode = 0 // 0:PC 1:mobile

    console.log("[info] successful match");

    const timestamp = new Date().getTime(); // 获取当前时间戳
    console.log("[info] timestamp:"+timestamp); // 输出当前时间戳

    const div = document.createElement('div');
    const img = document.createElement('img');
    const span = document.createElement('span')

    div.appendChild(img);
    div.appendChild(span);

    img.src = 'https://az15297.vo.msecnd.net/images/rewards.svg'; // 设置 img 的 src 属性

    img.id = "mrs_img_auto";
    div.style.position = 'fixed'; // 设置定位方式为固定定位
    div.style.top = '15%'; // 设置 img 的上边缘距离屏幕顶部的距离为 0
    div.style.left = '3%'; // 设置 img 的左边缘距离屏幕左侧的距离为 0

    span.textContent = "0";
    span.style.color = "red";
    span.style.fontWeight = 'bold';
    span.style.display = 'flex';
    span.style.alignItems = 'center';
    span.style.justifyContent = 'center';

    num = parseInt(localStorage.getItem('mrs_count_num'), 10);
    mode = parseInt(localStorage.getItem('mrs_count_mode'), 10);
    if(!isNaN(num)&&num!=0)
    {
        span.textContent = ""+num;
        console.log("[info] count:"+num);
        num = num - 1;
        localStorage.setItem('mrs_count_num',num);

        const url = "https://cn.bing.com/search?q="+timestamp; // 目标网页的地址
        window.open(url, "_self"); // 在当前页面中打开目标网页
    }

    img.addEventListener('click', function() { // 添加点击事件监听器
        const n = window.prompt('Please enter a number(Number of searches):');
        num = parseInt(n, 10);
         if(!isNaN(num)&&num!=0) {
             span.textContent = ""+num;
             console.log("[info] first count:"+num);
             num = num - 1;

             localStorage.setItem('mrs_count_num',num);;

             const url = "https://cn.bing.com/search?q="+timestamp; // 目标网页的地址
             window.open(url, "_self"); // 在当前页面中打开目标网页

         }else
         {
             console.log("[info] cancel");
         }
    });


    document.getElementById('b_content').appendChild(div);

})();