MSGPIntegration

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

当前为 2022-02-10 提交的版本,查看 最新版本

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