diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/content_script.js b/content_script.js new file mode 100644 index 0000000..264615f --- /dev/null +++ b/content_script.js @@ -0,0 +1,76 @@ +var person; + +loadReplace(); + +function loadReplace() +{ +chrome.storage.local.get("person", function(value) +{ +person = value.person; +walk(document.body); +} +) +} + +function walk(node) +{ + // I stole this function from here: + // http://is.gd/mwZp7E + + var child, next; + + switch ( node.nodeType ) + { + case 1: // Element + case 9: // Document + case 11: // Document fragment + child = node.firstChild; + while ( child ) + { + next = child.nextSibling; + walk(child); + child = next; + } + break; + + case 3: // Text node + handleText(node); + break; + } +} + +function handleText(textNode) +{ + var v = textNode.nodeValue; + + v = v.replace("Y/N", person); + v = v.replace("y/n", person); + v = v.replace("Y/n", person); + v = v.replace("y/N", person); + v = v.replace("(Y/N)", person); + v = v.replace("(y/n)", person); + v = v.replace("(Y/n)", person); + v = v.replace("(y/N)", person); + v = v.replace("Y/N?", person + "?"); + v = v.replace("y/n?", person + "?"); + v = v.replace("Y/n?", person + "?"); + v = v.replace("y/N?", person + "?"); + v = v.replace("Y/N!", person + "!"); + v = v.replace("y/n!", person + "!"); + v = v.replace("Y/n!", person + "!"); + v = v.replace("y/N!", person + "!"); + v = v.replace("(Y/N)?", person + "?"); + v = v.replace("(y/n)?", person + "?"); + v = v.replace("(Y/n)?", person + "?"); + v = v.replace("(y/N)?", person + "?"); + v = v.replace("(Y/N)!", person + "!"); + v = v.replace("(y/n)!", person + "!"); + v = v.replace("(Y/n)!", person + "!"); + v = v.replace("(y/N)!", person + "!"); + + + + textNode.nodeValue = v; +} + + diff --git a/icon-128.png b/icon-128.png new file mode 100644 index 0000000..5f36693 Binary files /dev/null and b/icon-128.png differ diff --git a/icon-16.png b/icon-16.png new file mode 100644 index 0000000..debb2f0 Binary files /dev/null and b/icon-16.png differ diff --git a/icon-48.png b/icon-48.png new file mode 100644 index 0000000..5e1df4e Binary files /dev/null and b/icon-48.png differ diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..aaf512f Binary files /dev/null and b/icon.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..ff48946 --- /dev/null +++ b/manifest.json @@ -0,0 +1,26 @@ +{ + "manifest_version": 2, + "name": "Interactive Fics", + "version": "1.0", + "description": "Replaces Y/N in Reader Insert/second person fics with a name of your choice.", + "browser_action": { + "default_icon": "icon.png", + "default_popup": "popup.html" }, + "permissions": [ + "storage", + "tabs"], + "icons": { "16": "icon-16.png", + "48": "icon-48.png", + "128": "icon-128.png" }, + "content_scripts": + [ + { + "matches": ["*://*/*"], + "js": ["content_script.js"], + "run_at": "document_end" + } + ], + "incognito": "split" + +} + diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..175bb7e --- /dev/null +++ b/popup.html @@ -0,0 +1,49 @@ + + + + +Interactive Fics + + + + + + + + + +

Enter the name here:

+ +

+

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.
+

+ + + + + + \ No newline at end of file diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..d5eb552 --- /dev/null +++ b/popup.js @@ -0,0 +1,10 @@ +document.addEventListener('DOMContentLoaded', function () { + document.querySelector('button').addEventListener('click', clickHandler); +}); //instead of onclick="clickHandler()" in popup.html + + +function clickHandler(){ +var person = document.getElementById("inputTxt").value; +chrome.storage.local.set({"person": person}, chrome.tabs.reload()); +} +