MSGPIntegration

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

当前为 2022-05-31 提交的版本,查看 最新版本

  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 TheLastZombie/userscripts
  10. // @version 1.0.5
  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. // @compatible chrome
  15. // @compatible edge
  16. // @compatible firefox
  17. // @compatible opera
  18. // @compatible safari
  19. // @homepageURL https://thelastzombie.github.io/userscripts/
  20. // @supportURL https://github.com/TheLastZombie/userscripts/issues/new?labels=MSGPIntegration
  21. // @contributionURL https://ko-fi.com/rcrsch
  22. // @contributionAmount €1.00
  23. // @author TheLastZombie <roesch.eric+userscripts@protonmail.com>
  24. // @include https://www.microsoft.com/*/p/*/*
  25. // @match https://www.microsoft.com/*/p/*/*
  26. // @connect store.rg-adguard.net
  27. // @run-at document-end
  28. // @inject-into auto
  29. // @grant GM.xmlHttpRequest
  30. // @grant GM_xmlhttpRequest
  31. // @noframes
  32. // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
  33. // @icon https://thelastzombie.github.io/userscripts/icons/MSGPIntegration.ico
  34. // @copyright 2021-2022, TheLastZombie (https://eric.jetzt/)
  35. // @license MIT; https://thelastzombie.github.io/userscripts/LICENSE
  36. // ==/UserScript==
  37.  
  38. // ==OpenUserJS==
  39. // @author TheLastZombie
  40. // ==/OpenUserJS==
  41.  
  42. (function () {
  43. "use strict";
  44.  
  45. document
  46. .getElementById("buttonPanel")
  47. .insertAdjacentHTML(
  48. "afterend",
  49. "<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>"
  50. );
  51.  
  52. const lang = location.pathname.split("/")[1];
  53. const url = location.pathname.split("/")[4];
  54.  
  55. GM.xmlHttpRequest({
  56. method: "POST",
  57. url: "https://store.rg-adguard.net/api/GetFiles",
  58. data: "type=ProductId&url=" + url + "&lang=" + lang,
  59. headers: {
  60. "Content-Type": "application/x-www-form-urlencoded",
  61. },
  62. onload: function (response) {
  63. const element = document.createElement("html");
  64. element.innerHTML = response.responseText;
  65.  
  66. if (
  67. element.getElementsByTagName("p")[0].innerText !==
  68. "The links were successfully received from the Microsoft Store server."
  69. ) {
  70. document.getElementById("msgpintegration-text").innerText =
  71. "No links found.";
  72. return;
  73. }
  74.  
  75. document
  76. .getElementById("msgpintegration-button")
  77. .removeAttribute("disabled");
  78. document.getElementById("msgpintegration-text").innerText =
  79. element.getElementsByClassName("tftable")[0].rows.length -
  80. 1 +
  81. " links found.";
  82.  
  83. document.body.insertAdjacentHTML(
  84. "beforeend",
  85. "<div id='msgpintegration-background'></div>"
  86. );
  87. document
  88. .getElementById("msgpintegration-background")
  89. .insertAdjacentElement(
  90. "beforeend",
  91. element.getElementsByClassName("tftable")[0]
  92. );
  93. document.getElementsByTagName("head")[0].insertAdjacentHTML(
  94. "beforeend",
  95. `
  96. <style>
  97. #msgpintegration-background {
  98. position: fixed;
  99. top: 0;
  100. left: 0;
  101. width: 100vw;
  102. height: 100vh;
  103. z-index: 999;
  104. background-color: rgba(24, 26, 27, 0.9);
  105. padding: 5em;
  106. overflow-y: auto;
  107. display: none;
  108. }
  109. .tftable {
  110. background-color: white;
  111. }
  112. </style>
  113. `
  114. );
  115.  
  116. document
  117. .getElementById("msgpintegration-button")
  118. .addEventListener("click", function () {
  119. document.getElementById("msgpintegration-background").style.display =
  120. "initial";
  121. });
  122.  
  123. document
  124. .getElementById("msgpintegration-background")
  125. .addEventListener("click", function (e) {
  126. if (
  127. e.target === document.getElementById("msgpintegration-background")
  128. )
  129. document.getElementById(
  130. "msgpintegration-background"
  131. ).style.display = "none";
  132. });
  133. },
  134. });
  135. })();
  136.  
  137. // @license-end