// @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
// @downloadURL none
// ==/UserScript==
// ==OpenUserJS==
// @author TheLastZombie
// ==/OpenUserJS==
(function () {
document.getElementById('buttonPanel').insertAdjacentHTML('afterend', "
")
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', "")
document.getElementById('msgpintegration-background').insertAdjacentElement('beforeend', element.getElementsByClassName('tftable')[0])
document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', `
`)
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