From 746a74af99ef35af21d75432f1a1050dae0a3c7c Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sun, 7 May 2017 14:19:40 +0200 Subject: [PATCH] Prefix minified content by file type. Avoid naming collisions and prefix the minified scripts by JS_ so that it's obvious what's their content. --- src/Makefile | 6 +++--- src/normal.c | 2 +- src/scripts/js2h.sh | 2 +- src/setting.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Makefile b/src/Makefile index ae8d14b..50e267d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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) diff --git a/src/normal.c b/src/normal.c index 73c9a3a..9ea22ef 100644 --- a/src/normal.c +++ b/src/normal.c @@ -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); diff --git a/src/scripts/js2h.sh b/src/scripts/js2h.sh index 4a76777..4a50c12 100755 --- a/src/scripts/js2h.sh +++ b/src/scripts/js2h.sh @@ -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 | \ diff --git a/src/setting.c b/src/setting.c index f9fcfb2..0df1881 100644 --- a/src/setting.c +++ b/src/setting.c @@ -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); -- 2.20.1