Don not double inject user script file.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 21 Apr 2017 21:10:39 +0000 (23:10 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 21 Apr 2017 21:10:39 +0000 (23:10 +0200)
The script file is injected in case 'userscripts' setting is enabled. So
there is no need to do this on creating the webview too.

src/main.c

index 05a3239..7a97f51 100644 (file)
@@ -1600,8 +1600,6 @@ static WebKitWebView *webview_new(Client *c, WebKitWebView *webview)
 {
     WebKitWebView *new;
     WebKitUserContentManager *ucm;
-    WebKitUserScript *script;
-    char *js = NULL;
 
     /* create a new webview */
     if (webview) {
@@ -1629,15 +1627,6 @@ static WebKitWebView *webview_new(Client *c, WebKitWebView *webview)
 
     g_signal_connect(webkit_web_context_get_default(), "download-started", G_CALLBACK(on_webctx_download_started), c);
 
-    /* Inject the user script file. */
-    if (g_file_get_contents(vb.files[FILES_SCRIPT], &js, NULL, NULL)) {
-        script = webkit_user_script_new(js,
-                WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES,
-                WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END, NULL, NULL);
-        webkit_user_content_manager_add_script(ucm, script);
-        webkit_user_script_unref(script);
-    }
-
     /* Setup script message handlers. */
     webkit_user_content_manager_register_script_message_handler(ucm, "focus");
     g_signal_connect(ucm, "script-message-received::focus", G_CALLBACK(on_script_message_focus), c);