Advertisement
Guest User

background.js

a guest
Jul 2nd, 2012
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. chrome.webRequest.onCompleted.addListener(
  2. function(details) {
  3.     //if (details.url.substring(0, 23) == "https://www.google.com/") // I know I do not need this
  4.     //{
  5.         console.info("URL :" + details.url);
  6.         FindData("http://www.altavista.com");
  7.     //}
  8. },
  9. // filters
  10. {
  11.     urls: [
  12.         "http://*.google.com/*",
  13.         "https://*.google.com/*",
  14.     ],
  15.     types: ["image"]
  16. },
  17. ["responseHeaders"]);
  18.  
  19. function FindData(strURL) {
  20.     var req = new XMLHttpRequest();
  21.     req.open("GET", strURL, true);
  22.     req.onreadystatechange=function() {
  23.         if (req.readyState==4) {
  24.             if (req.status==200)
  25.             {
  26.                 console.info("Sucess!");
  27.                 console.info("Data: " + req.responseText);
  28.             }
  29.         else if (req.status==404) console.info("URL doesn't exist!")
  30.         else console.info("Error: Status is " + req.status)
  31.         }
  32.     }
  33.     req.send();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement