Xbox-Now.com

Just go on the page, and press ARROW UP

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Xbox-Now.com
// @namespace    XN	
// @version      1.0
// @description  Just go on the page, and press ARROW UP
// @author       XN
// @match        https://www.microsoft.com/*/p/*
// @require      https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant       GM_notification
// @grant       window.focus
// ==/UserScript==

(function() {
  'use strict';

  var flagAutobuy = false;
  var flagNextButtonClicked = false;

  var timeRefresh = 200;

  $(window).keydown(function(event) {
      if (event.which == 38) startAutoBuy();
      else if (event.which == 40) stopAutoBuy();
  });


  $("body").bind('DOMNodeInserted', function(event) {
    if (flagAutobuy)
    {
      if ($(event.target).attr('id') == 'wb_auto_blend_container')
      {
        flagNextButtonClicked = false;

        goClickConfirmButton();
      }
    }
  });

  function goClickConfirmButton()
  {
    if ($('#wb_auto_blend_container').contents().find('#confirmButton').length > 0)
    {
      $('#wb_auto_blend_container').contents().find('#confirmButton').click();
      checkNextButton();
    }
    else
    {
      setTimeout(goClickConfirmButton, timeRefresh);
    }
  }

  function checkNextButton()
  {
    if ($('#wb_auto_blend_container').contents().find('.cli_errorCode').length > 0 &&
      $('#wb_auto_blend_container').contents().find('.cli_errorCode').text() == 'PUR-UserAlreadyOwnsContent')
    {
      flagAutobuy = false;
      GM_notification({
        text: 'BUY OK',
        title: "Xbox-Now.com",
        onclick: function() { window.focus(); },
      });
    }
    else
    {
      if ($('#wb_auto_blend_container').contents().find('#cancelButton').length > 0)
      {
        $('#wb_auto_blend_container').contents().find('#cancelButton').click();
        goClickBuyButton();

        flagNextButtonClicked = true;
        setTimeout(checkNextButton, timeRefresh);
      }
      else
      {
        if (flagNextButtonClicked == false)
        {
          setTimeout(checkNextButton, timeRefresh);
        }
        else
        {
          goClickBuyButton();
        }
      }
    }

  }




  function checkNextButton2()
  {
    if ($('#wb_auto_blend_container').contents().find('#cancelButton').length > 0)
    {
      $('#wb_auto_blend_container').contents().find('#cancelButton').click();
      goClickBuyButton();

      flagNextButtonClicked = true;
      setTimeout(checkNextButton, timeRefresh);
    }
    if ($('#wb_auto_blend_container').contents().find('#cli_errorCode').length > 0 &&
      $('#wb_auto_blend_container').contents().find('#cli_errorCode').text() == 'PUR-UserAlreadyOwnsContent')
    {
      flagAutobuy = false;
      GM_notification({
        text: 'BUY OK',
        title: "Xbox-Now.com",
        onclick: function() { window.focus(); },
      });
    }
    else
    {
      if (flagNextButtonClicked == false)
      {
        setTimeout(checkNextButton, timeRefresh);
      }
      else
      {
        goClickBuyButton();
      }
    }
  }

  function goClickBuyButton()
  {
    if ($('body').find('#buttonPanel_AppIdentityBuyButton').length > 0)
    {
      $('body').find('#buttonPanel_AppIdentityBuyButton').click();
    }
  }

  function startAutoBuy()
  {
    flagAutobuy = true;
    GM_notification({
      text: 'Autobuyer enabled',
      title: "Xbox-Now.com",
      onclick: function() { window.focus(); },
    });
  }

  function stopAutoBuy()
  {
    flagAutobuy = false;
    GM_notification({
      text: 'Autobuyer disabled',
      title: "Xbox-Now.com",
      onclick: function() { window.focus(); },
    });
  }


})();