MSGPIntegration

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

当前为 2021-08-19 提交的版本,查看 最新版本

  1. // @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT
  2. /* eslint-env browser, greasemonkey */
  3.  
  4. // ==UserScript==
  5. // @name MSGPIntegration
  6. // @name:de MSGPIntegration
  7. // @name:en MSGPIntegration
  8. // @namespace https://github.com/TheLastZombie/
  9. // @version 1.0.0
  10. // @description Allows access to the Microsoft Store Generation Project from within Microsoft Store itself.
  11. // @description:de Integriert das Microsoft Store Generation Project in den Microsoft Store selbst.
  12. // @description:en Allows access to the Microsoft Store Generation Project from within Microsoft Store itself.
  13. // @homepageURL https://github.com/TheLastZombie/userscripts#msgpintegration-
  14. // @supportURL https://github.com/TheLastZombie/userscripts/issues/new?labels=MSGPIntegration
  15. // @contributionURL https://ko-fi.com/rcrsch
  16. // @author TheLastZombie
  17. // @match https://www.microsoft.com/*/p/*/*
  18. // @connect store.rg-adguard.net
  19. // @grant GM.xmlHttpRequest
  20. // @grant GM_xmlhttpRequest
  21. // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
  22. // @icon https://raw.githubusercontent.com/TheLastZombie/userscripts/master/icons/MSGPIntegration.ico
  23. // @copyright 2021, TheLastZombie (https://github.com/TheLastZombie/)
  24. // @license MIT; https://github.com/TheLastZombie/userscripts/blob/master/LICENSE
  25. // ==/UserScript==
  26.  
  27. // ==OpenUserJS==
  28. // @author TheLastZombie
  29. // ==/OpenUserJS==
  30.  
  31. (function () {
  32. 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>")
  33.  
  34. const lang = location.pathname.split('/')[1]
  35. const url = location.pathname.split('/')[4]
  36.  
  37. GM.xmlHttpRequest({
  38. method: 'POST',
  39. url: 'https://store.rg-adguard.net/api/GetFiles',
  40. data: 'type=ProductId&url=' + url + '&lang=' + lang,
  41. headers: {
  42. 'Content-Type': 'application/x-www-form-urlencoded'
  43. },
  44. onload: function (response) {
  45. const element = document.createElement('html')
  46. element.innerHTML = response.responseText
  47.  
  48. if (!element.getElementsByTagName('p')[0].innerText === 'The links were successfully received from the Microsoft Store server.') {
  49. document.getElementById('msgpintegration-text').innerText = 'No links found.'
  50. return
  51. }
  52.  
  53. document.getElementById('msgpintegration-button').removeAttribute('disabled')
  54. document.getElementById('msgpintegration-text').innerText = element.getElementsByClassName('tftable')[0].rows.length - 1 + ' links found.'
  55.  
  56. document.body.insertAdjacentHTML('beforeend', "<div id='msgpintegration-background'></div>")
  57. document.getElementById('msgpintegration-background').insertAdjacentElement('beforeend', element.getElementsByClassName('tftable')[0])
  58. document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', `
  59. <style>
  60. #msgpintegration-background {
  61. position: fixed;
  62. top: 0;
  63. left: 0;
  64. width: 100vw;
  65. height: 100vh;
  66. z-index: 999;
  67. background-color: rgba(24, 26, 27, 0.9);
  68. padding: 5em;
  69. overflow-y: auto;
  70. display: none;
  71. }
  72. .tftable {
  73. background-color: white;
  74. }
  75. </style>
  76. `)
  77.  
  78. document.getElementById('msgpintegration-button').addEventListener('click', function () {
  79. document.getElementById('msgpintegration-background').style.display = 'initial'
  80. })
  81.  
  82. document.getElementById('msgpintegration-background').addEventListener('click', function (e) {
  83. if (e.target === document.getElementById('msgpintegration-background')) document.getElementById('msgpintegration-background').style.display = 'none'
  84. })
  85. }
  86. })
  87. })()
  88.  
  89. // @license-end