This commit is contained in:
Mariam Maarouf 2020-05-21 17:26:38 +02:00
parent 8a1b005484
commit 9e734d33c9
2 changed files with 7 additions and 3 deletions

View File

@ -27,10 +27,14 @@ const replaceAllInStorage = (items) => {
} }
const escapeAndReplace = (input_word, replace_value, case_sensitive) => { const escapeAndReplace = (input_word, replace_value, case_sensitive) => {
if (input_word.length == 0) { return; }
let input_word_escaped = escapeRegExp(input_word.trim()) let input_word_escaped = escapeRegExp(input_word.trim())
const flags = case_sensitive ? "g" : "ig" const flags = case_sensitive ? "g" : "ig"
if (!input_word_escaped.startsWith('\\')) { if (input_word_escaped[0].match(/[a-z]/i)) {
input_word_escaped = `\\b${input_word_escaped}\\b` 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) const regexp_input_word = new RegExp(input_word_escaped, flags)
replace(regexp_input_word, replace_value) replace(regexp_input_word, replace_value)

View File

@ -3,7 +3,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "InteractiveFics", "name": "InteractiveFics",
"author": "mariamrf", "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.", "description": "Replaces Y/N & other variables in Reader Insert/second person fics with words of your choice.",
"browser_action": { "browser_action": {
"default_title": "InteractiveFics", "default_title": "InteractiveFics",