Prefix minified content by file type.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 7 May 2017 12:19:40 +0000 (14:19 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 7 May 2017 12:19:40 +0000 (14:19 +0200)
Avoid naming collisions and prefix the minified scripts by JS_ so that
it's obvious what's their content.

src/Makefile
src/normal.c
src/scripts/js2h.sh
src/setting.c

index ae8d14b..50e267d 100644 (file)
@@ -1,9 +1,9 @@
 BASEDIR=..
 include $(BASEDIR)/config.mk
 
-SUBDIRS = webextension
-OBJ     = $(patsubst %.c, %.o, $(wildcard *.c))
-JSFILES = $(wildcard scripts/*.js)
+SUBDIRS  = webextension
+OBJ      = $(patsubst %.c, %.o, $(wildcard *.c))
+JSFILES  = $(wildcard scripts/*.js)
 
 all: vimb $(SUBDIRS:%=%.subdir-all)
 
index 73c9a3a..9ea22ef 100644 (file)
@@ -495,7 +495,7 @@ static VbResult normal_increment_decrement(Client *c, const NormalCmdInfo *info)
     char *js;
     int count = info->count ? info->count : 1;
 
-    js = g_strdup_printf(INCREMENT_URI_NUMBER, info->key == CTRL('A') ? count : -count);
+    js = g_strdup_printf(JS_INCREMENT_URI_NUMBER, info->key == CTRL('A') ? count : -count);
     ext_proxy_eval_script(c, js, NULL);
     g_free(js);
 
index 4a76777..4a50c12 100755 (executable)
@@ -15,7 +15,7 @@ fi
 
 # Remove the path and .js file extension and turn all chars to upper case to
 # get the constant name.
-CONSTANT=$(echo "$FILE" | sed 's:.*/::g' | sed 's:.js$::g' | tr a-z A-Z)
+CONSTANT=$(echo "$FILE" | sed 's:.*/::g' | sed 's:^\(.*\).\(js\):\2_\1:g' | tr a-z A-Z)
 
 # minify the script
 cat $FILE | \
index f9fcfb2..0df1881 100644 (file)
@@ -621,7 +621,7 @@ static int user_scripts(Client *c, const char *name, DataType type, void *value,
     }
 
     /* Inject the global hints script. */
-    script = webkit_user_script_new(HINTS,
+    script = webkit_user_script_new(JS_HINTS,
             WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,
             WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END, NULL, NULL);
     webkit_user_content_manager_add_script(ucm, script);