From 9e734d33c965981eed4a75ed48774d88d711ee37 Mon Sep 17 00:00:00 2001 From: Mariam Maarouf Date: Thu, 21 May 2020 17:26:38 +0200 Subject: [PATCH] v5.0.5 --- content_script.js | 8 ++++++-- manifest.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/content_script.js b/content_script.js index dc89a2b..be30f09 100644 --- a/content_script.js +++ b/content_script.js @@ -27,10 +27,14 @@ const replaceAllInStorage = (items) => { } const escapeAndReplace = (input_word, replace_value, case_sensitive) => { + if (input_word.length == 0) { return; } let input_word_escaped = escapeRegExp(input_word.trim()) const flags = case_sensitive ? "g" : "ig" - if (!input_word_escaped.startsWith('\\')) { - input_word_escaped = `\\b${input_word_escaped}\\b` + if (input_word_escaped[0].match(/[a-z]/i)) { + input_word_escaped = `\\b${input_word_escaped}` + } + if (input_word_escaped[input_word_escaped.length - 1].match((/[a-z]/i))) { + input_word_escaped = `${input_word_escaped}\\b` } const regexp_input_word = new RegExp(input_word_escaped, flags) replace(regexp_input_word, replace_value) diff --git a/manifest.json b/manifest.json index f2f937a..80bffa8 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "manifest_version": 2, "name": "InteractiveFics", "author": "mariamrf", - "version": "5.0.4", + "version": "5.0.5", "description": "Replaces Y/N & other variables in Reader Insert/second person fics with words of your choice.", "browser_action": { "default_title": "InteractiveFics",