So I am trying to add a new scene to PA via a mod. I want to scene to be hosted on my server, so I can modify it if necessary. My current work looks like this: The html of the paage: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Searching...</title> <script src="coui://ui/alpha/shared/js/common.js" type="text/javascript"></script> <script src="ranked_matcher.js" type="text/javascript"></script> </head> <body style="overflow: hidden"> <!-- VERSION INFO __________________________________________________________________________--> <div id="version_info"> <div class="div_version_info_cont"> <span>BETA v.<span data-bind="text: buildVersion"></span></span> </div> </div> <div class="div_body_overlay"> </div> </body> </html> So this makes it load the common.js from the local PA installation via the coui:// url. However, that file contains stuff like this: Code: function loadScript(src) { console.log(src, "loading script"); var o = new XMLHttpRequest(); try { o.open('GET', src, false); o.send(''); } catch( err ) { console.log("error loading " + src) return; } var se = document.createElement('script'); se.type = "text/javascript"; se.text = o.responseText; document.getElementsByTagName('head')[0].appendChild(se); } loadScript("../shared/js/boot.js"); This results in this kind of error: The location of my scene in this case was local on my machine @ coui://pa_stats/scenes/ranked_matcher/ranked_matcher.html So it seems the ../ is translated and it returns a path that is based on the current path. Just like one would expect from a relative loadScript with .. But that sucks, how am I supposed to load the local PA library stuff like this? I don't want to copy the whole shared folder of PA obviously. Any ideas how this can be corrected from my side? I cannot insert any code between the definition of loadScript and the calls to loadScript, so I guess I am out of luck here? @Uber: PLEASE fix this and use coui:// style absolute path at least in the shared libraries so we can load them from wherever we want. EDIT: Based on Yrrep's code here is my solution. I load this as the first js file: Code: XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open; var newOpen = function(method, src, async, user, password) { // only modify the next 2 calls if (src.substring(0, 2) === "..") { var upCnt = 0; while(src.substring(0, 2) === "..") { upCnt++; // delete the first 3 letters: ../ src = src.substring(3, src.length); } if (upCnt == 1) { src = "coui://ui/alpha/"+src; } else { src = "coui://ui/"+src; } console.log("will request: "+src); } else { console.log("wont change: "+src); } this.realOpen(method, src, async, user, password); } XMLHttpRequest.prototype.open = newOpen; In Addition this call needs to be done in some js of the scene: loadCSS("coui://ui/alpha/shared/css/boot.css"); EDIT: Oh *** This is the normal localstorage: This happens once I am on my own host: It's obviously empty. But I need stuff from the storage. ???!
You can try intercepting the XMLHttpRequest.open call made by the loadScript function: Code: XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open; var newOpen = function(method, url, async, user, password) { console.log("Intercepted open (" + url + ")"); this.realOpen(method, url, async, user, password); } XMLHttpRequest.prototype.open = newOpen; I understand that's exactly what you're already trying to do. If that doesn't work out, you can always set up your server to answer calls not made to your scene's resources. No need to copy PA resources, just return a script containing a loadScript call with the absolute coui:// path. That way PA should load the correct script shortly afterwards. (We're already discussing this on IRC, just wanted to add it for reference.)