0

Im using a very very old site that displays 3D models on canvasses using JSC3D (Yes, THAT old) and I want to access the scene during runtime if possible... I know userscripts (specifically with greasemonkey) can access and modify scripts before theyre run in the runtime... So if possible I may have to use that... however I have no experience with userscripts, nor any idea how to make "mutation observers" or anything of the sort

The script itself is structured like this:

var App = App || {};
App = function (D) {
    var a = new JSC3D.Viewer(D); // Variable I need to see during / after runtime
    // a.scene -> target I need to access  
    ...

The "App" instance is all I can see in the runtime, but I seemingly cant grab the scene or the JSC3D instance as a whole.

My goal is to access a.scene so I can export an old model. The code to download the STL from the scene is already provided by the developer, but in this specific case, the scene variable is not accessible from the webview Im accessing.

And no, sadly the model data is not visible in the network calls / resources. They use a binary encoder / decoder to store all the info into one file, so Im being forced to use a runtime method to attempt to get the model.

1 Answer 1

0

Alright, turns out I was overthinking it, the solution was really simple.

All I had to do was intercept one of the calls made regularly / often during runtime (in this case, scene.getChild(x), and set a global variable to the scene.

Then I could just call the scene in the downloader and it works flawlessly.

// @grant unsafeWindow

window.addEventListener('load', function() {
    JSC3D.Scene.prototype.getChild = function (a) {
        unsafeWindow.scene = this;
        return this.children[a]; // business as usual / sustain default behavior
    };

    unsafeWindow.downloadStl = function() { .. do stuff with scene variable here .. }

    downloadStl(); // can call from anywhere if you use unsafeWindow
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .