]> spindle.queued.net Git - midori/commitdiff
Run userscripts on DOMContentsLoaded
authorArnaud Renevier <arenevier@fdn.fr>
Mon, 21 Jul 2008 23:40:39 +0000 (01:40 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 21 Jul 2008 23:40:39 +0000 (01:40 +0200)
midori/midori-addons.c

index 2f8ddb48e61e25c81d9fab629e5cdf7f1e2303c0..0bdd1334857c511ec0ed88d2ce647e1eeba3a741 100644 (file)
@@ -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);