made base for reading from file

This commit is contained in:
ksjdragon 2015-02-26 19:54:23 -05:00
parent 08e58bae35
commit b582aa4fbb
4 changed files with 50 additions and 12 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "Substitution", "name": "Substitution",
"version": "1.0", "version": "0.1.1",
"manifest_version": 2, "manifest_version": 2,
"description": "Replaces words for amusement.", "description": "Replaces words for amusement.",
"homepage_url": "http://extensionizr.com", "homepage_url": "http://extensionizr.com",
@ -19,7 +19,7 @@
"options_page": "src/options/index.html", "options_page": "src/options/index.html",
"browser_action": { "browser_action": {
"default_icon": "icons/icon19.png", "default_icon": "icons/icon19.png",
"default_title": "browser action demo" "default_title": "Substitute?"
}, },
"permissions": [ "permissions": [
"https://*/*", "https://*/*",

View File

@ -1,4 +1,4 @@
document.documentElement.innerHTML = /*document.documentElement.innerHTML =
document.documentElement.innerHTML document.documentElement.innerHTML
.replace(/witnesses/g, "these dudes I know") .replace(/witnesses/g, "these dudes I know")
.replace(/allegedly/g, "kinda probably") .replace(/allegedly/g, "kinda probably")
@ -20,5 +20,27 @@ document.documentElement.innerHTML
.replace(/radioactive/g, "kinda dangerous") .replace(/radioactive/g, "kinda dangerous")
.replace(/Democratic Party/g, "Elephants") .replace(/Democratic Party/g, "Elephants")
.replace(/Republican Party/g, "Donkeys") .replace(/Republican Party/g, "Donkeys")
.replace(/Democratic-Donkeys/g, "Elephant-Donkeys"); .replace(/Democratic-Donkeys/g, "Elephant-Donkeys");*/
//add all var html = document.documentElement.innerHTML;
var wordsReplacee = [];
var wordsReplacer = [];
var test = "witnesses these dudes I know\nallegedly kinda probably\npresident garbage man\ngive gib";
//^ this is where we reference the reading of file
var file = test.split(/[\s]/);
for( var i = 0; i < file.length ; i+=2 ) {
wordsReplacee.push(file[i]);
wordsReplacer.push(file[i+1]);
console.log(wordsReplacee);
console.log(wordsReplacer);
}
for( var a = 0; a < wordsReplacee.length; a++ ) {
var reg = new RegExp(wordsReplacee[a], "gi");
if (a = 0) {
htmlReplaced = html.replace(reg, wordsReplacer);
} else {
htmlReplaced = htmlReplaced.replace(reg, wordsReplacer);
}
}

View File

@ -0,0 +1,7 @@
hi
bye
asdf
asdh
asdhasdf
asdhasdddd
asdhasdhasdf

View File

@ -1,9 +1,18 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<title></title> <meta charset="utf-8">
</head> <meta http-equiv="X-UA-Compatible" content="chrome=1">
<body> <title>IA Chromebook Sign-Out</title>
</body> <link rel="stylesheet" href="stylesheets/mainStyle.css">
</html> <link rel="icon" href="../resources/ico/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<p>Options</p>
</body>
</html>