workbench.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8" />
  6. <meta name="mobile-web-app-capable" content="yes" />
  7. <meta name="apple-mobile-web-app-capable" content="yes" />
  8. <meta name="apple-mobile-web-app-title" content="Code">
  9. <link rel="apple-touch-icon" href="https://app.itk.academy/favicon.svg" />
  10. <meta name="viewport"
  11. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  12. <meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONFIGURATION}}">
  13. <meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
  14. <link rel="icon" href="https://app.itk.academy/favicon.svg">
  15. <link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json"
  16. crossorigin="use-credentials" />
  17. </head>
  18. <body>
  19. <div>
  20. <div>ИТК. Академия Хэде 0ldр! {{WORKBENCH_WEB_BASE_URL}}</div>
  21. <div aria-label=""></div>
  22. </div>
  23. </body>
  24. <script>
  25. function logs() {
  26. }
  27. (function () {
  28. // Save the original fetch function
  29. const originalFetch = window.fetch;
  30. // Override the fetch function
  31. window.fetch = function (resource, config) {
  32. // Check if the request URL matches the one you want to suppress
  33. if (typeof resource === 'string' && resource.includes('vsda.js')) {
  34. alert('ok')
  35. // Return a resolved promise with a mock response
  36. return Promise.resolve({
  37. ok: false,
  38. status: 404,
  39. statusText: 'Not Found',
  40. url: resource,
  41. json: () => Promise.resolve({}),
  42. text: () => Promise.resolve(''),
  43. });
  44. }
  45. // For all other requests, proceed with the original fetch
  46. return originalFetch(resource, config)
  47. .then(response => {
  48. // Handle responses for other requests if needed
  49. return response;
  50. })
  51. .catch(error => {
  52. // Handle errors for other requests if needed
  53. throw error;
  54. });
  55. };
  56. })();
  57. (function () {
  58. // Save original console methods
  59. const originalConsole = {
  60. log: console.log,
  61. error: console.error,
  62. warn: console.warn,
  63. info: console.info,
  64. debug: console.debug,
  65. };
  66. // Function to check if the log is from an iframe
  67. function isLogFromIframe() {
  68. const errorStack = new Error().stack; // Get the stack trace
  69. return errorStack.includes("HTMLIFrameElement"); // Check if the stack includes iframe
  70. }
  71. // Override console methods
  72. console.log = function (...args) {
  73. if (isLogFromIframe()) {
  74. originalConsole.log.apply(console, args); // Allow logs from iframe
  75. }
  76. };
  77. console.error = function (...args) {
  78. if (isLogFromIframe()) {
  79. originalConsole.error.apply(console, args); // Allow errors from iframe
  80. }
  81. };
  82. console.warn = function (...args) {
  83. if (isLogFromIframe()) {
  84. originalConsole.warn.apply(console, args); // Allow warnings from iframe
  85. }
  86. };
  87. console.info = function (...args) {
  88. if (isLogFromIframe()) {
  89. originalConsole.info.apply(console, args); // Allow info logs from iframe
  90. }
  91. };
  92. console.debug = function (...args) {
  93. if (isLogFromIframe()) {
  94. originalConsole.debug.apply(console, args); // Allow debug logs from iframe
  95. }
  96. };
  97. })();
  98. const wbUrl = "{{WORKBENCH_WEB_BASE_URL}}"
  99. const baseUrl = new URL(wbUrl, window.location.origin).toString();
  100. globalThis._VSCODE_FILE_ROOT = baseUrl + '/out/';
  101. let isFast = window.location.href.indexOf('fast=1') > -1;
  102. let domain = isFast ? 'https://localhost:7000' : globalThis._VSCODE_FILE_ROOT;
  103. if (!isFast) {
  104. runCssDirect(` footer [aria-label=remote]:after{content:'ITK Academy CodeRun';font-weight:700}.actions-container[role=tablist]{display:flex!important;flex-direction:column!important}.actions-container[role=tablist] li{order:2!important}.actions-container[role=tablist] li:first-child{order:0!important}.actions-container[role=tablist] li:last-child:has([aria-label*="ITK Academy"]){order:1!important} `)
  105. insertCssLink(domain + "/vs/code/browser/workbench/workbench.css")
  106. runBlob(domain + "/vs/code/browser/workbench/workbench.js")
  107. runBlob(domain + "/nls.messages.js")
  108. } else {
  109. runCss(domain + "/vs/code/browser/workbench/workbench.css")
  110. runBlob(domain + "/vs/code/browser/workbench/workbench.js")
  111. runBlob(domain + "/nls.messages.js")
  112. }
  113. function insertCssLink(href) {
  114. var link = document.createElement('link');
  115. link.rel = 'stylesheet'; // Specify it's a stylesheet
  116. link.href = href; // Specify the CSS file path
  117. document.head.appendChild(link);
  118. }
  119. function runCssDirect(text) {
  120. let style = document.createElement("style");
  121. style.textContent = text;
  122. document.head.appendChild(style);
  123. }
  124. function runCss(url) {
  125. fetch(url)
  126. .then(response => response.text())
  127. .then(css => {
  128. runCssDirect(isFast ? css.replace(/\/media\//g, (v) => {
  129. // return domain + '/media/'
  130. return globalThis._VSCODE_FILE_ROOT + '/media/'
  131. }) : css)
  132. })
  133. .catch(error => {
  134. // console.error("Failed to load CSS:", error)
  135. });
  136. }
  137. function runBlob(src) {
  138. fetch(src)
  139. .then(response => {
  140. if (!response.ok) {
  141. // throw new Error(`HTTP error! Status: ${response.status}`);
  142. return;
  143. }
  144. return response.text();
  145. })
  146. .then(scriptText => {
  147. const code = scriptText//`export function test() { return 'Hello, Modules!'; }`;
  148. const blob = new Blob([code], { type: 'application/javascript' });
  149. const url = URL.createObjectURL(blob);
  150. import(url).then((module) => {
  151. // console.log(module.test()); // Output: Hello, Modules!
  152. });
  153. // eval(scriptText)
  154. })
  155. .catch(error => {
  156. // console.error("Failed to load script:", error)
  157. });
  158. }
  159. </script>
  160. </html>