Run userscripts on DOMContentsLoaded

This commit is contained in:
Arnaud Renevier 2008-07-22 01:40:39 +02:00 committed by Christian Dywan
parent 4580486d36
commit 030a6af57c

View file

@ -171,12 +171,14 @@ _js_script_from_file (JSContextRef js_context,
gboolean result = FALSE; gboolean result = FALSE;
gchar* script; gchar* script;
GError* error = NULL; GError* error = NULL;
gchar* wrapped_script;
if (g_file_get_contents (filename, &script, NULL, &error)) if (g_file_get_contents (filename, &script, NULL, &error))
{ {
/* Wrap the script to prevent global variables */ /* Wrap the script to prevent global variables */
gchar* wrapped_script = g_strdup_printf ( wrapped_script = g_strdup_printf (
"(function () { %s })();", script); "window.addEventListener ('DOMContentLoaded',"
"function () { %s }, true);", script);
if (gjs_script_eval (js_context, wrapped_script, exception)) if (gjs_script_eval (js_context, wrapped_script, exception))
result = TRUE; result = TRUE;
g_free (wrapped_script); g_free (wrapped_script);