Permalink
Browse files

initial checkin

  • Loading branch information...
0 parents commit d6eff15947e035a31688a8358b07f982f8f31b3a @chrismatthieu committed May 2, 2011
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<!--
+ * Copyright (c) 2011 Chris Matthieu. All rights reserved. Use of this
+ * source code is governed by the Apache 2 license.
+-->
+<html>
+ <head>
+ </head>
+ <body>
+ <script>
+ /**
+ * Opens PhonoPhone when the browser action is clicked.
+ * Used window.open because I didn't want the tabs permission.
+ */
+ chrome.browserAction.onClicked.addListener(function() {
+ window.open('http://phonophone.heroku.com', 'telephone', 'width=350,height=400');
+ });
+ </script>
+ </body>
+</html>
@@ -0,0 +1,30 @@
+var regex = /[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}/g;
+var page;
+var hits;
+
+// Test the text of the body element against our regular expression.
+if (regex.test(document.body.innerText)) {
+ // The regular expression produced a match, so notify the background page.
+
+ page = document.body.innerText;
+
+ hits = page.match(regex)
+
+ for (var i = 0; i < hits.length; i += 1) {
+ // page = page.replace(hits[i], '<a href="http://phonophone.heroku.com?phone=' + trimString(hits[i]) + '">' + hits[i] + '</a>');
+ page = page.replace(hits[i], '<a href="#" onclick="javascript:window.open(\'http://phonophone.heroku.com?phone=' + trimString(hits[i]) + '\' , \'popup_id\', \'scrollbars,resizable,width=350,height=400\')">' + hits[i] + '</a>');
+ }
+
+ document.write (page);
+
+ chrome.extension.sendRequest({}, function(response) {});
+
+} else {
+ // No match was found.
+}
+
+
+//To trim leading or trailing spaces
+function trimString (str) {
+ return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,24 @@
+{
+ "name" : "Phono",
+ "version" : "0.1.0",
+ "description" : "PhonoPhone",
+ "background_page" : "background.html",
+ "browser_action" : {
+ "default_icon" : "logo-32.png"
+ },
+ "content_scripts" : [
+ {
+ "matches" : [
+ "http://*/*",
+ "https://*/*"
+ ],
+ "js" : ["contentscript.js"],
+ "run_at" : "document_idle"
+ }
+ ],
+ "icons" : {
+ "16" : "logo-16.png",
+ "48" : "logo-48.png",
+ "128" : "logo-128.png"
+ }
+}

0 comments on commit d6eff15

Please sign in to comment.