Guest User

Untitled

a guest
Feb 20th, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // contentscript.js:
  2. chrome.extension.sendRequest({}, function(responseText) {
  3.     // .... ???? Function logic ????
  4.     // Let's assume that the responseText contains the CSS url.
  5.     var currentTheme = responseText + '.css';
  6.     var style = document.createElement('link');
  7.     style.type = "text/css";
  8.     style.rel = "stylesheet";
  9.     style.href = currentTheme;
  10.     (document.head||document.documentElement.firstElementChild).appendChild(style);
  11. });
  12.  
  13.  
  14. // background page:
  15. chrome.extension.onRequest.addListener(function(request, sender, callback) {
  16.     var xhttp = new XMLHttpRequest();
  17.     xhttp.onreadystatechange = function() {
  18.         if(xhttp.readystate == 4) {
  19.              callback(xhttp.responseText);
  20.              xhttp.onreadystatechange = xhttp.open = xhttp.send = null;
  21.              xhttp = null;
  22.         }
  23.     }
  24.     xhttp.open("post", "http://localhost:8888/g_dta.php", true);
  25.     xhttp.send(request.data);
  26. });
Advertisement
Add Comment
Please, Sign In to add comment