Access "name" attribute of the window in window.wrappedJSObject

Hi everyone. I’m trying to access the name attribute of a window but I’m unsure of the correct syntax in this case due to the wrapped object. I’m doing this in a script executed by a frame script.

 Object.defineProperty(window.wrappedJSObject["Self"].prototype,
 "name",
 {
     writable: true,
     value: "test"
});

Accessing others such as the navigator via the wrapped object works fine .

Any ideas ?

Thanks

To clarify I’m trying to override window properties from a frame script. I have successfully modified the navigator and screen properties of a window but I also need to modify the name and inner/outer width/height properties of the window itself using frame scripts .

The only way I could get the screen and navigator interfaces to work was using window.wrappedJSObject but now I need to attributes of the window object directly.

Has anyone got any ideas of how I could modify those properties inside a frame script ?

window.name = “whatever” worked inside a frame script if anyone else is wondering. I still need to figure out how to modify the size attributes of the window but I will deal with that in a new issue.

1 Like

Aw man no one came to help you out. It’s nice to see you made progress.

Tapping into the scope with wrappedJSObject will do the trick. I prefer not to do that though. I set up a messaging comm layer, and postMessage to the window, which returns to me the value.

Hi noitidart. It’s not exactly the standard use case so I did not imagine that too many people would have tried something similar. Using your approach can you modify the window size properties such as innerheight, outerwidth and so on ?

I send a message to the contentWindow, the message is a method name i defined in the contentWindow scope. So the message i send from the framscript triggers this function, which can do anything it wants as its in the same scope.

I haven’t made it totally ready so you can copy paste (im actually working on making this a clean api right now), but this is my comm layer -

basically it calls a function in the other side B, and triggers a callback with the return value in side A (the triggering side).

framescript side:
https://github.com/Noitidart/Profilist/blob/4ff90d1e297fe867bcf049512f55886add2681fb/resources/scripts/MainFramescript.js#L213-L292

And then contentwindow side:
https://github.com/Noitidart/Profilist/blob/4ff90d1e297fe867bcf049512f55886add2681fb/resources/scripts/fsReturnIconset.js#L345-L445

I’ll have to look into something like that if I can’t get window size to work. Thanks