From 030a6af57c93a3a79b308e7384110a248350e13a Mon Sep 17 00:00:00 2001 From: Arnaud Renevier Date: Tue, 22 Jul 2008 01:40:39 +0200 Subject: [PATCH] Run userscripts on DOMContentsLoaded --- midori/midori-addons.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/midori/midori-addons.c b/midori/midori-addons.c index 2f8ddb48..0bdd1334 100644 --- a/midori/midori-addons.c +++ b/midori/midori-addons.c @@ -171,12 +171,14 @@ _js_script_from_file (JSContextRef js_context, gboolean result = FALSE; gchar* script; GError* error = NULL; + gchar* wrapped_script; if (g_file_get_contents (filename, &script, NULL, &error)) { /* Wrap the script to prevent global variables */ - gchar* wrapped_script = g_strdup_printf ( - "(function () { %s })();", script); + wrapped_script = g_strdup_printf ( + "window.addEventListener ('DOMContentLoaded'," + "function () { %s }, true);", script); if (gjs_script_eval (js_context, wrapped_script, exception)) result = TRUE; g_free (wrapped_script);