Wrap userscripts in an anonymous function.
This commit is contained in:
parent
e45fe65278
commit
5b731c45ba
1 changed files with 4 additions and 1 deletions
|
@ -521,8 +521,11 @@ _js_document_load_script_file (JSContextRef js_context,
|
|||
GError* error = NULL;
|
||||
if (g_file_get_contents (filename, &script, NULL, &error))
|
||||
{
|
||||
if (_js_eval (js_context, script, exception))
|
||||
gchar* wrapped_script = g_strdup_printf (
|
||||
"var wrapped = function () { %s }; wrapped ();", script);
|
||||
if (_js_eval (js_context, wrapped_script, exception))
|
||||
result = TRUE;
|
||||
g_free (wrapped_script);
|
||||
g_free (script);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue