Source

flv_download / background.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <script>
      var knownSites = new Array(
         {
            name: 'Generic site...',
            vidUrl: /(http:\/\/[^ "]*.flv)/,
         },
         {
            regex: /http:\/\/.*((tube8)|(novamov)|(libclip)).com/,
            name: 'Tube8 / Novamov / LibClip',
            vidUrl: /(http:\/\/[^ "]*.flv)/,
         },
         {
            regex: /http:\/\/.*evilangel.com/,
            name: 'Evil Angel',
            vidUrl: /(http:\/\/trailers.evilangel.com\/.*.flv)/
         },
         {
            regex: /http:\/\/.*elegantangel.com\/trailer/,
            name: 'Elegant Angel',
            vidUrl: /(http:\/\/data.elegantangel.com\/FLV_Trailers\/.*.flv)/,
         },
         {
            regex: /http:\/\/.*xhamster.com\/movies/,
            name: 'X Hamster',
            srvUrl: /'srv': '(http:\/\/[\d\.]*\/)'/,
            addUrl: "flv2/",
            vidUrl: /'file': '([^']*.flv)'/,
         },
         {
            regex: /http:\/\/((.*xvideos)|(video.xnxx)).com\/video/,
            name: 'XVideos / XNXX',
            vidUrl: /'(http:\/\/[^ "']*.flv[^']*)'/,
         },
         {
            regex: /http:\/\/.*dailymotion.com\/video/,
            name: 'Dailymotion',
            normalize: true,
            vidUrl: /(http:\/\/www.dailymotion.com\/cdn\/FLV.*.flv[^@]*)@@/,
         },
         {
            regex: /http:\/\/.*youporn.com\/watch/,
            name: 'YouPorn',
            vidUrl: /"(http:\/\/download.youporn.com\/download\/[^"]*)">FLV/,
         },
         {
            regex: /http:\/\/.*youtube.com\//,
            name: 'YouTube',
            normalize: true,
            vidUrl: /"fmt_url_map": "35\|[^"\|]*\|(http:\/\/[^\|,]*)%2C5\|/,
         },
         {
            regex: /http:\/\/.*liveleak.com\//,
            name: 'LiveLeak',
            normalize: true,
            vidUrl: /convert_url = "([^"]*)"/,
         }
      );
            /* FIXME
            else if (/http:\/\/.*megavideo.com\//.test(t.url)) {
               myDiv.innerHTML = 'MegaVideo';
               vid_url = /embed src="(http:\/\/www.megavideo.com\/v\/[^"]*)"/;
            }*/
      chrome.tabs.onSelectionChanged.addListener(function(tabId, selectInfo) {
         checkUrl(tabId);
      });
      chrome.tabs.onCreated.addListener(function(tab) {
         checkUrl(tab.id);
      });
      chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
         checkUrl(tabId);
      });
      function checkUrl(tabId) {
         chrome.tabs.get(tabId, function(tab) {
            if (knownUrl(tab.url)) {
               chrome.browserAction.setBadgeText({text: "ok"});
               chrome.browserAction.setBadgeBackgroundColor({
                  color: [255, 128, 0, 200]});
            } else {
               chrome.browserAction.setBadgeText({text: ''});
            }
         });
      };
      function knownUrl(url) {
         var found = false;
         var i = knownSites.length - 1;
         while ((! found) && (i>0))
            if (knownSites[i].regex.test(url))
               found = true;
            else
               i--;
         return i;
      };
      function bgLoad() {
         chrome.tabs.getSelected(null,function(tab){
            checkUrl(tab.id)
         });
      };
   </script>
</head>
<body onload="bgLoad();">
</body>
</html>