Now, I'm working with userscript for a browser game. And I have some problems with sandbox and initialization.
As a solution, I found a way with creating a new element (script) and inserting the object in element.
var script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML = "var Class = { ... }";
document.body.appendChild(script);
But I have a very large object and convert it to a string rather problematic and time consuming.
I have an object that looks like this:
{
addToStorage : Function,
getFromStorage : Function,
getID : Function
settings : Object,
langs : Object,
init : Function,
version : Number,
author: String
}
Any ideas, how to convert it to string or insert into global window?
Sorry for my bad English.