Run userscripts on DOMContentsLoaded
This commit is contained in:
parent
4580486d36
commit
030a6af57c
1 changed files with 4 additions and 2 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue