Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Chrome Extension

By: a guest on Jul 23rd, 2011  |  syntax: JavaScript  |  size: 0.52 KB  |  views: 310  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // background.html
  2. // ---------------------
  3. <script src="sample.js"></script>
  4.  
  5. // sample.js
  6. // ---------------------
  7. var localS = 0;
  8. chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
  9.     if (request.count>0){
  10.                 localS=request.count;
  11.                 sendResponse({msg: "thanks"});
  12.         }
  13.     else
  14.                 sendResponse({});
  15. });
  16.  
  17. // contentscript.js
  18. // ---------------------
  19. var c = localStorage["engine_count"];
  20. chrome.extension.sendRequest({count: [c]}, function(response) {
  21.   console.log(response.msg);
  22. });