From: Christian Dywan Date: Sat, 3 May 2008 23:34:39 +0000 (+0200) Subject: Wrap userscripts in an anonymous function. X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b731c45ba4f48b7ddb05ee2111de973b8b2d11d;p=midori Wrap userscripts in an anonymous function. --- diff --git a/src/midori-addons.c b/src/midori-addons.c index c5cbe6e1..552f7972 100644 --- a/src/midori-addons.c +++ b/src/midori-addons.c @@ -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