MSGPIntegration

Allows access to the Microsoft Store Generation Project from within Microsoft Store itself.

目前為 2021-08-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT
/* eslint-env browser, greasemonkey */

// ==UserScript==
// @name            MSGPIntegration
// @name:de         MSGPIntegration
// @name:en         MSGPIntegration
// @namespace       https://github.com/TheLastZombie/
// @version         1.0.0
// @description     Allows access to the Microsoft Store Generation Project from within Microsoft Store itself.
// @description:de  Integriert das Microsoft Store Generation Project in den Microsoft Store selbst.
// @description:en  Allows access to the Microsoft Store Generation Project from within Microsoft Store itself.
// @homepageURL     https://github.com/TheLastZombie/userscripts#msgpintegration-
// @supportURL      https://github.com/TheLastZombie/userscripts/issues/new?labels=MSGPIntegration
// @contributionURL https://ko-fi.com/rcrsch
// @author          TheLastZombie
// @match           https://www.microsoft.com/*/p/*/*
// @connect         store.rg-adguard.net
// @grant           GM.xmlHttpRequest
// @grant           GM_xmlhttpRequest
// @require         https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @icon            https://raw.githubusercontent.com/TheLastZombie/userscripts/master/icons/MSGPIntegration.ico
// @copyright       2021, TheLastZombie (https://github.com/TheLastZombie/)
// @license         MIT; https://github.com/TheLastZombie/userscripts/blob/master/LICENSE
// ==/UserScript==

// ==OpenUserJS==
// @author          TheLastZombie
// ==/OpenUserJS==

(function () {
  document.getElementById('buttonPanel').insertAdjacentHTML('afterend', "<div id='msgpintegration-wrapper' class='pi-button-panel'><div class='pi-overflow-ctrl'><button id='msgpintegration-button' class='c-button' disabled><span id='msgpintegration-text'>Loading...</span></button></div></div>")

  const lang = location.pathname.split('/')[1]
  const url = location.pathname.split('/')[4]

  GM.xmlHttpRequest({
    method: 'POST',
    url: 'https://store.rg-adguard.net/api/GetFiles',
    data: 'type=ProductId&url=' + url + '&lang=' + lang,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    onload: function (response) {
      const element = document.createElement('html')
      element.innerHTML = response.responseText

      if (!element.getElementsByTagName('p')[0].innerText === 'The links were successfully received from the Microsoft Store server.') {
        document.getElementById('msgpintegration-text').innerText = 'No links found.'
        return
      }

      document.getElementById('msgpintegration-button').removeAttribute('disabled')
      document.getElementById('msgpintegration-text').innerText = element.getElementsByClassName('tftable')[0].rows.length - 1 + ' links found.'

      document.body.insertAdjacentHTML('beforeend', "<div id='msgpintegration-background'></div>")
      document.getElementById('msgpintegration-background').insertAdjacentElement('beforeend', element.getElementsByClassName('tftable')[0])
      document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', `
        <style>
          #msgpintegration-background {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 999;
            background-color: rgba(24, 26, 27, 0.9);
            padding: 5em;
            overflow-y: auto;
            display: none;
          }
          .tftable {
            background-color: white;
          }
        </style>
      `)

      document.getElementById('msgpintegration-button').addEventListener('click', function () {
        document.getElementById('msgpintegration-background').style.display = 'initial'
      })

      document.getElementById('msgpintegration-background').addEventListener('click', function (e) {
        if (e.target === document.getElementById('msgpintegration-background')) document.getElementById('msgpintegration-background').style.display = 'none'
      })
    }
  })
})()

// @license-end