diff --git a/content_script.js b/content_script.js index e820b1a..3c8052e 100644 --- a/content_script.js +++ b/content_script.js @@ -1,15 +1,19 @@ +DISABLE_KEY = 'deactivate-this-extension-pls-interactive-fics-yalla-bina'; + var valChange = /\by\/n\b|\(y\/n\)|\[y\/n\]/ig; var person; var replaceAll = function (){ chrome.storage.local.get(null, function(items){ - for(var key in items){ - if(items[key]){ - if(key=="person") - loadReplace(valChange, items[key]); - else{ - var s = escapeRegExp(key); - var temp = new RegExp(s, "ig"); - loadReplace(temp, items[key]); + if(items[DISABLE_KEY] !== true){ + for(var key in items){ + if(items[key]){ + if(key=="person") + loadReplace(valChange, items[key]); + else if(key !== DISABLE_KEY){ + var s = escapeRegExp(key); + var temp = new RegExp(s, "ig"); + loadReplace(temp, items[key]); + } } } } @@ -22,7 +26,6 @@ function escapeRegExp(str) { } chrome.extension.onMessage.addListener(function(message,sender,sendResponse){ - //This is where the stuff you want from the background page will be var s = escapeRegExp(message.stuff); var val = new RegExp(s, "ig"); if(message.isYN) @@ -35,8 +38,12 @@ chrome.extension.onMessage.addListener(function(message,sender,sendResponse){ function loadReplace(rep, p){ - if(p!=null) - walk(document.body, rep, p); + chrome.storage.local.get(DISABLE_KEY, function(obj){ + var enabled = obj[DISABLE_KEY] !== true; + if(p!=null && enabled){ + walk(document.body, rep, p); + } + }); } function walk(node, v, p){ @@ -66,20 +73,4 @@ function handleText(textNode, val, p){ textNode.nodeValue = v; } -MutationObserver = window.MutationObserver || window.WebKitMutationObserver; - -var observer = new MutationObserver(function(mutations, observer) { - replaceAll(); -}); - -// define what element should be observed by the observer -// and what types of mutations trigger the callback -observer.observe(document, { - subtree: true, - childList: true - //... -}); - -//main - replaceAll(); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 1ac58a1..c6b5fa4 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "manifest_version": 2, "name": "InteractiveFics", - "version": "4.2", + "version": "4.4", "description": "Replaces Y/N & other variables in Reader Insert/second person fics with words of your choice.", "browser_action": { "default_icon": "icon.png", diff --git a/popup.html b/popup.html index d201560..5ce1012 100644 --- a/popup.html +++ b/popup.html @@ -34,10 +34,23 @@ label *:not([type="checkbox"]){ .otherWords .change{ margin-right:0; } -#clear-name{ +#clear-name, #deactivate{ margin-top:0.5em; width:96%; } +#deactivate{ + background-color: #9b59b6; + color:white; + border:0px; + border-radius:0.5em; + transition-duration: 0.5s; +} +#deactivate:hover{ + color: #9b59b6; + background-color: white; + cursor:pointer; +} + input[type="text"]{ width:70%; } @@ -62,7 +75,7 @@ input[type="text"]{
(This change will go away when you refresh/go to another page unless you check the box next to "Store this replacement")Need to replace something other than Y/N?
About
Interactive Fics is a free Chrome extension developed by blaringsilence to improve your online story reading experience. The extension is open source and all source code can be found here.
+
+
Feedback, suggestions and requests.