MSGPIntegration

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

当前为 2023-07-19 提交的版本,查看 最新版本

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