DCSS Webtiles Extension Module Loader

Load the DWEM from other Webtiles sites as well.

当前为 2024-04-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DCSS Webtiles Extension Module Loader
  3. // @description Load the DWEM from other Webtiles sites as well.
  4. // @version 1.0
  5. // @author refracta
  6. // @match http://webzook.net:8080/*
  7. // @match https://crawl.kelbi.org/*
  8. // @match http://crawl.akrasiac.org:8080/*
  9. // @match https://underhound.eu:8080/*
  10. // @match https://cbro.berotato.org:8443/*
  11. // @match http://lazy-life.ddo.jp:8080/*
  12. // @match https://crawl.xtahua.com/*
  13. // @match https://crawl.project357.org/*
  14. // @match http://joy1999.codns.com:8081/*
  15. // @grant none
  16. // @run-at document-start
  17. // @namespace https://greasyfork.org/users/467840
  18. // ==/UserScript==
  19.  
  20. (function () {
  21. 'use strict';
  22. const [head] = document.getElementsByTagName('head');
  23.  
  24. function haltRequireJS() {
  25. const scripts = head.getElementsByTagName('script');
  26. const rjsScript = Array.from(scripts).find(s => s.src?.endsWith('require.js'));
  27. rjsScript.remove();
  28.  
  29. const newRJSScript = document.createElement('script');
  30. newRJSScript.src = rjsScript.src;
  31. newRJSScript.setAttribute('data-main', rjsScript.getAttribute('data-main'));
  32.  
  33. const generateDummyAttributes = () => {
  34. let value;
  35. return {
  36. configurable: true, get: () => value, set: newValue => value = newValue
  37. };
  38. }
  39.  
  40. Object.defineProperty(window, 'define', generateDummyAttributes());
  41. Object.defineProperty(window, 'require', generateDummyAttributes());
  42. Object.defineProperty(window, 'requirejs', generateDummyAttributes());
  43.  
  44. window.reloadRequireJS = () => {
  45. window.require = window.define = window.requirejs = undefined;
  46. head.appendChild(newRJSScript);
  47. };
  48. }
  49.  
  50. haltRequireJS();
  51. // github.io
  52. import('https://refracta.github.io/dcss-webtiles-extension-module/loader/dwem-core-loader.js');
  53.  
  54. // CDN
  55. // import('TODO: CDN');
  56.  
  57. // Local server
  58. // import('http://localhost:6060/loader/dwem-core-loader.js');
  59. })();