MSGPIntegration

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

当前为 2023-01-02 提交的版本,查看 最新版本

  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 sun/userscripts
  10. // @version 2.0.3
  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://codeberg.org/sun/userscripts
  20. // @supportURL https://codeberg.org/sun/userscripts/issues/new
  21. // @contributionURL https://liberapay.com/sun
  22. // @contributionAmount €1.00
  23. // @author Sunny <roesch.eric+userscripts@protonmail.com>
  24. // @include https://apps.microsoft.com/store/detail/*/*
  25. // @match https://apps.microsoft.com/store/detail/*/*
  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://codeberg.org/sun/userscripts/raw/branch/main/icons/MSGPIntegration.ico
  34. // @copyright 2021-present, Sunny
  35. // @license MIT; https://codeberg.org/sun/userscripts/src/branch/main/LICENSE
  36. // ==/UserScript==
  37.  
  38. // ==OpenUserJS==
  39. // @author TheLastZombie
  40. // ==/OpenUserJS==
  41.  
  42. (function () {
  43. "use strict";
  44.  
  45. const observer = new MutationObserver((mutationList, observer) => {
  46. mutationList.forEach((mutation) => {
  47. if (
  48. Array.from(mutation.addedNodes).filter((node) =>
  49. node.classList.contains("c013")
  50. ).length
  51. ) {
  52. observer.disconnect();
  53.  
  54. document
  55. .querySelector("[id^=getOrRemoveButton]")
  56. .insertAdjacentHTML(
  57. "afterend",
  58. "<button id='msgpintegration-button' class='c0151 c0158' style='border-radius: 4px; padding: 0 20px; margin-bottom: 4px' disabled><span id='msgpintegration-text'>Loading...</span></button>"
  59. );
  60. }
  61. });
  62. });
  63.  
  64. observer.observe(document.body, {
  65. childList: true,
  66. subtree: true,
  67. });
  68.  
  69. const url = location.pathname.split("/")[4];
  70.  
  71. GM.xmlHttpRequest({
  72. method: "POST",
  73. url: "https://store.rg-adguard.net/api/GetFiles",
  74. data: "type=ProductId&url=" + url + "&lang=en_US",
  75. headers: {
  76. "Content-Type": "application/x-www-form-urlencoded",
  77. },
  78. onload: function (response) {
  79. const element = document.createElement("html");
  80. element.innerHTML = response.responseText;
  81.  
  82. if (
  83. element.getElementsByTagName("p")[0].innerText !==
  84. "The links were successfully received from the Microsoft Store server."
  85. ) {
  86. document.getElementById("msgpintegration-text").innerText =
  87. "No links found.";
  88. return;
  89. }
  90.  
  91. document
  92. .getElementById("msgpintegration-button")
  93. .classList.remove("c0158");
  94. document
  95. .getElementById("msgpintegration-button")
  96. .removeAttribute("disabled");
  97. document.getElementById("msgpintegration-text").innerText =
  98. element.getElementsByClassName("tftable")[0].rows.length -
  99. 1 +
  100. " links found.";
  101.  
  102. document.body.insertAdjacentHTML(
  103. "beforeend",
  104. "<div id='msgpintegration-background'></div>"
  105. );
  106. document
  107. .getElementById("msgpintegration-background")
  108. .insertAdjacentElement(
  109. "beforeend",
  110. element.getElementsByClassName("tftable")[0]
  111. );
  112. document.getElementsByTagName("head")[0].insertAdjacentHTML(
  113. "beforeend",
  114. `
  115. <style>
  116. #msgpintegration-background {
  117. position: fixed;
  118. top: 0;
  119. width: 100vw;
  120. height: 100vh;
  121. z-index: 701;
  122. background-color: white;
  123. overflow-y: auto;
  124. display: none;
  125. }
  126. .tftable {
  127. margin: 3em auto;
  128. }
  129. @media (min-width: 1035px) {
  130. .tftable {
  131. margin-top: calc(3em + 54px);
  132. }
  133. }
  134. </style>
  135. `
  136. );
  137.  
  138. document
  139. .getElementById("msgpintegration-button")
  140. .addEventListener("click", function () {
  141. document.getElementById("msgpintegration-background").style.display =
  142. "initial";
  143. });
  144.  
  145. document
  146. .getElementById("msgpintegration-background")
  147. .addEventListener("click", function (e) {
  148. if (
  149. e.target === document.getElementById("msgpintegration-background")
  150. )
  151. document.getElementById(
  152. "msgpintegration-background"
  153. ).style.display = "none";
  154. });
  155. },
  156. });
  157. })();
  158.  
  159. // @license-end