loader.html 850 B

12345678910111213141516171819202122232425262728293031
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8'>
  5. <style>
  6. body {
  7. margin: 0;
  8. }
  9. </style>
  10. </head>
  11. <body>
  12. ...
  13. <script>
  14. const testData = JSON.parse(decodeURIComponent(location.hash.substring(1)));
  15. const script = testData.script;
  16. import(testData.script).then(async Module => {
  17. try {
  18. const result = await Module.test();
  19. if (result) {
  20. document.body.innerHTML = "ok";
  21. parent.postMessage(JSON.stringify({ script }), "*");
  22. }
  23. } catch (error) {
  24. parent.postMessage(JSON.stringify({ script, error: { message: error.message, stack: error.stack } }), "*");
  25. throw error;
  26. }
  27. })
  28. </script>
  29. </body>