diff --git a/content_script.js b/content_script.js index 43fd44e..c72581e 100644 --- a/content_script.js +++ b/content_script.js @@ -1,7 +1,11 @@ DEACTIVATE_KEY = 'deactivate-this-extension-pls-interactive-fics-yalla-bina'; chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { - escapeAndReplace(message.input_word, message.replace_value, message.case_sensitive) + if ('input_word' in message){ + escapeAndReplace(message.input_word, message.replace_value, message.case_sensitive) + } else { + replaceAll() + } }); const replaceAll = () => { diff --git a/popup.css b/popup.css index 2a5bd9f..09ea0da 100644 --- a/popup.css +++ b/popup.css @@ -30,10 +30,23 @@ label *:not([type="checkbox"]){ .other-words .change{ margin-right:0; } -#clear-name, #deactivate{ +#clear-name, #deactivate, #refresh-replacements{ margin-top:0.5em; width:96%; } + +#refresh-replacements { + margin-top: 1.5em; + font-size: 1.005em; + background-color: #D9B08C; + border-radius: 0.5em; + color: white; +} + +#refresh-replacements:hover { + color: black; +} + #deactivate{ background-color: #116466; color:white; diff --git a/popup.html b/popup.html index a5ba1da..7b1f4c0 100644 --- a/popup.html +++ b/popup.html @@ -15,6 +15,9 @@
+
+ +
Need to replace something other than Y/N?

This change will go away when you refresh/go to another page unless you check the box next to "Store this replacement".

diff --git a/popup.js b/popup.js index 151e014..de9a1cd 100644 --- a/popup.js +++ b/popup.js @@ -5,6 +5,7 @@ document.addEventListener('DOMContentLoaded', function () { document.getElementById('change-name-form').addEventListener('submit', changeName) document.getElementById('clear-name-form').addEventListener('submit', clearName) document.getElementById('replace-other-words-form').addEventListener('submit', replaceOther) + document.getElementById('refresh-replacements-form').addEventListener('submit', refreshReplacements) document.getElementById('show-saved').addEventListener('click', loadSaved) document.getElementById('deactivate').addEventListener('click', toggleDeactivate) @@ -48,6 +49,16 @@ const replaceOther = () => { } } +const refreshReplacements = () => { + chrome.tabs.query({ active: true, currentWindow: true }, tabs => { + chrome.tabs.sendMessage( + tabs[0].id, + { + refresh: true + }) + }) +} + const loadSaved = () => { chrome.storage.sync.get(null, items => { const list = document.getElementById('saved-items-list')