Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 5cbb0418061d19e272a9f47af15a2e9503d1d362 Mauricio Reyes committed Feb 23, 2012
Showing with 122 additions and 0 deletions.
  1. +9 −0 background.html
  2. +90 −0 background.js
  3. +4 −0 jquery-1.7.1.min.js
  4. +19 −0 manifest.json
  5. BIN play.png
  6. BIN stop.png
@@ -0,0 +1,9 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Background Page</title>
+ <script src="background.js"></script>
+ </head>
+ <body>
+ </body>
+</html>
@@ -0,0 +1,90 @@
+var interval;
+var origin = "";
+var running = true;
+
+chrome.tabs.onUpdated.addListener(function() {
+ play();
+});
+
+function play() {
+ chrome.tabs.executeScript(null, { file: "jquery-1.7.1.min.js" }, function() {
+ if (running){
+ chrome.browserAction.setIcon({path:"play.png"});
+ chrome.tabs.executeScript(null, {code:"try{clearInterval(interval)}catch(e){}"});
+ running = false;
+ }
+ else{
+ chrome.browserAction.setIcon({path:"stop.png"});
+ chrome.tabs.executeScript(null,
+ {code:"function get_source(){url=window.url;domain=location.protocol+'//'+location.hostname+(location.port?':'+location.port:'');$.ajax({url:url,async:false,cache:false,dataType:'text',success:function(a){source=a}});css_src=source.match(/(href=(\"|\'))[^http].+(\.css)/g);$.each(css_src,function(a,b){css_src[a]=css_src[a].replace(/href=(\"|\')/,domain)});js_src=source.match(/(src=(\"|\'))[^http].+(\.js)/g);$.each(js_src,function(a,b){js_src[a]=js_src[a].replace(/src=(\"|\')/,domain)});$.each(css_src,function(a,b){$.ajax({url:b,async:false,cache:false,dataType:'text',success:function(a){source+=a}})});$.each(js_src,function(a,b){$.ajax({url:b,async:false,cache:false,dataType:'text',success:function(a){source+=a}})});return source}var origin=get_source();interval=setInterval(function(){source=get_source();if(origin!=source){origin=source;history.go(0)}},1e3)"});
+ running = true;
+ }
+ });
+}
+
+chrome.browserAction.onClicked.addListener(play);
+play();
+
+/*
+function get_source(){
+ url = window.url;
+ domain = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '');
+ // get html data
+ $.ajax({
+ url: url,
+ async:false,
+ cache:false,
+ dataType:"text",
+ success: function(data) {
+ source = data;
+ }
+ });
+ // get css uri's
+ css_src = source.match(/(href=(\"|\'))[^http].+(\.css)/g);
+ $.each(css_src, function(i,v){
+ css_src[i]=css_src[i].replace(/href=(\"|\')/,domain);
+ });
+ // get js uri's
+ js_src = source.match(/(src=(\"|\'))[^http].+(\.js)/g);
+ $.each(js_src, function(i,v){
+ js_src[i]=js_src[i].replace(/src=(\"|\')/,domain);
+ });
+ // get css data
+ $.each(css_src, function(i,uri){
+ $.ajax({
+ url: uri,
+ async:false,
+ cache:false,
+ dataType:"text",
+ success: function(data) {
+ source += data;
+ }
+ });
+ });
+ // get js data
+ $.each(js_src, function(i,uri){
+ $.ajax({
+ url: uri,
+ async:false,
+ cache:false,
+ dataType:"text",
+ success: function(data) {
+ source += data;
+ }
+ });
+ });
+
+ return source;
+}
+
+var origin = get_source()
+interval = setInterval(function(){
+ source = get_source();
+
+ if (origin != source){
+ origin = source;
+ history.go(0);
+ }
+},1000);
+// compress with http://jscompress.com/
+*/

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,19 @@
+{
+ "name": "Live CSS Mod",
+ "version": "1.0",
+ "description": "Modify the HTML/CSS/JS code from your favorite text editor and it'll automatically refresh your web browser to see the changes.",
+ "content_scripts": [
+ {
+ "matches": ["http://www.google.com/*"],
+ "js": ["jquery-1.7.1.min.js", "background.js"]
+ }
+ ],
+ "background_page": "background.html",
+ "permissions": [
+ "tabs", "http://*/*"
+ ],
+ "browser_action": {
+ "name": "Click to change the icon's color"
+ },
+ "content_security_policy": "default-src 'self'"
+}
BIN play.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN stop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5cbb041

Please sign in to comment.