Inject global hints script during setting.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 7 May 2017 11:44:05 +0000 (13:44 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 7 May 2017 11:44:05 +0000 (13:44 +0200)
In case the user disabled user scripts, also the hints script was
removed from the web content manager. So if the page was reloaded the
hinting did not work. To avoid the disabling of vimb internal used
scripts, we set them always during set up of the settings. So they are
readded in case all scripts are removed from the web content manager.

src/main.c
src/setting.c

index 89988bf..22c6a8c 100644 (file)
@@ -40,7 +40,6 @@
 #include "main.h"
 #include "map.h"
 #include "normal.h"
-#include "scripts/scripts.h"
 #include "setting.h"
 #include "shortcut.h"
 #include "util.h"
@@ -1652,7 +1651,6 @@ static WebKitWebView *webview_new(Client *c, WebKitWebView *webview)
 {
     WebKitWebView *new;
     WebKitUserContentManager *ucm;
-    WebKitUserScript *script;
 
     /* create a new webview */
     if (webview) {
@@ -1680,13 +1678,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 global hints script. */
-    script = webkit_user_script_new(HINTS,
-            WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
-            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);
index 92b0f42..f9fcfb2 100644 (file)
@@ -25,6 +25,7 @@
 #include "ext-proxy.h"
 #include "main.h"
 #include "setting.h"
+#include "scripts/scripts.h"
 #include "shortcut.h"
 
 typedef enum {
@@ -619,6 +620,13 @@ static int user_scripts(Client *c, const char *name, DataType type, void *value,
         webkit_user_content_manager_remove_all_scripts(ucm);
     }
 
+    /* Inject the global hints script. */
+    script = webkit_user_script_new(HINTS,
+            WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
+            WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END, NULL, NULL);
+    webkit_user_content_manager_add_script(ucm, script);
+    webkit_user_script_unref(script);
+
     return CMD_SUCCESS;
 }