MSGPIntegration

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

  1. // ==UserScript==
  2. // @name MSGPIntegration
  3. // @name:de MSGPIntegration
  4. // @name:en MSGPIntegration
  5. // @namespace sun/userscripts
  6. // @version 2.0.12
  7. // @description Allows access to the Microsoft Store Generation Project from within Microsoft Store itself.
  8. // @description:de Integriert das Microsoft Store Generation Project in den Microsoft Store selbst.
  9. // @description:en Allows access to the Microsoft Store Generation Project from within Microsoft Store itself.
  10. // @compatible chrome
  11. // @compatible edge
  12. // @compatible firefox
  13. // @compatible opera
  14. // @compatible safari
  15. // @homepageURL https://forgejo.sny.sh/sun/userscripts
  16. // @supportURL https://forgejo.sny.sh/sun/userscripts/issues
  17. // @contributionURL https://liberapay.com/sun
  18. // @contributionAmount €1.00
  19. // @author Sunny <sunny@sny.sh>
  20. // @include https://apps.microsoft.com/store/detail/*/*
  21. // @match https://apps.microsoft.com/store/detail/*/*
  22. // @connect store.rg-adguard.net
  23. // @run-at document-end
  24. // @inject-into auto
  25. // @grant GM.addStyle
  26. // @grant GM_addStyle
  27. // @grant GM.xmlHttpRequest
  28. // @grant GM_xmlhttpRequest
  29. // @noframes
  30. // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
  31. // @icon https://forgejo.sny.sh/sun/userscripts/raw/branch/main/icons/MSGPIntegration.ico
  32. // @copyright 2021-present, Sunny (https://sny.sh/)
  33. // @license Hippocratic License; https://forgejo.sny.sh/sun/userscripts/src/branch/main/LICENSE.md
  34. // ==/UserScript==
  35.  
  36. (() => {
  37. const observer = new MutationObserver((mutationList, observer) => {
  38. for (const mutation of mutationList) {
  39. if (
  40. Array.from(mutation.addedNodes).filter((node) =>
  41. node.classList.contains("c013"),
  42. ).length
  43. ) {
  44. observer.disconnect();
  45.  
  46. document
  47. .querySelector("[id^=getOrRemoveButton]")
  48. .insertAdjacentHTML(
  49. "afterend",
  50. "<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>",
  51. );
  52. }
  53. }
  54. });
  55.  
  56. observer.observe(document.body, {
  57. childList: true,
  58. subtree: true,
  59. });
  60.  
  61. const url = location.pathname.split("/")[4];
  62.  
  63. GM.xmlHttpRequest({
  64. method: "POST",
  65. url: "https://store.rg-adguard.net/api/GetFiles",
  66. data: `type=ProductId&url=${url}&lang=en_US`,
  67. headers: {
  68. "Content-Type": "application/x-www-form-urlencoded",
  69. },
  70. onload: (response) => {
  71. const element = document.createElement("html");
  72. element.innerHTML = response.responseText;
  73.  
  74. if (
  75. element.getElementsByTagName("p")[0].innerText !==
  76. "The links were successfully received from the Microsoft Store server."
  77. ) {
  78. document.getElementById("msgpintegration-text").innerText =
  79. "No links found.";
  80. return;
  81. }
  82.  
  83. document
  84. .getElementById("msgpintegration-button")
  85. .classList.remove("c0158");
  86. document
  87. .getElementById("msgpintegration-button")
  88. .removeAttribute("disabled");
  89. document.getElementById("msgpintegration-text").innerText = `${
  90. element.getElementsByClassName("tftable")[0].rows.length - 1
  91. } links found.`;
  92.  
  93. document.body.insertAdjacentHTML(
  94. "beforeend",
  95. "<div id='msgpintegration-background'></div>",
  96. );
  97. document
  98. .getElementById("msgpintegration-background")
  99. .insertAdjacentElement(
  100. "beforeend",
  101. element.getElementsByClassName("tftable")[0],
  102. );
  103. GM.addStyle(`
  104. #msgpintegration-background {
  105. position: fixed;
  106. top: 0;
  107. width: 100vw;
  108. height: 100vh;
  109. z-index: 701;
  110. background-color: white;
  111. overflow-y: auto;
  112. display: none;
  113. }
  114. .tftable {
  115. margin: 3em auto;
  116. }
  117. @media (min-width: 1035px) {
  118. .tftable {
  119. margin-top: calc(3em + 54px);
  120. }
  121. }
  122. `);
  123.  
  124. document
  125. .getElementById("msgpintegration-button")
  126. .addEventListener("click", () => {
  127. document.getElementById("msgpintegration-background").style.display =
  128. "initial";
  129. });
  130.  
  131. document
  132. .getElementById("msgpintegration-background")
  133. .addEventListener("click", (e) => {
  134. if (
  135. e.target === document.getElementById("msgpintegration-background")
  136. )
  137. document.getElementById(
  138. "msgpintegration-background",
  139. ).style.display = "none";
  140. });
  141. },
  142. });
  143. })();