SHARE
TWEET

Chrome Extension

a guest Jul 23rd, 2011 330 Never
  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. });
RAW Paste Data
Top