gecko-mplayer: import from AlwaysInnovating overlay and clean it up a bit
authorKoen Kooi <koen@openembedded.org>
Thu, 1 Oct 2009 10:16:12 +0000 (12:16 +0200)
committerKoen Kooi <koen@openembedded.org>
Thu, 1 Oct 2009 11:12:00 +0000 (13:12 +0200)
conf/checksums.ini
recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome.manifest [new file with mode: 0644]
recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.js [new file with mode: 0644]
recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.xul [new file with mode: 0644]
recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/install.rdf [new file with mode: 0644]
recipes/gnome-mplayer/gecko-mediaplayer_0.9.8.bb [new file with mode: 0644]

index 2539828..3d20396 100644 (file)
@@ -6462,14 +6462,14 @@ sha256=c0810fb3ddb6cb73c9ff045965e542af6e3eaa7f2995b3037181766d26d5e6e7
 md5=9e3503116f4269a1be70220ee2234b0e
 sha256=6f5644d56cc603138533158076a6cb41cd33c33d27e5310cb76cb6576151ca67
 
-[http://ftp.gnome.org/pub/gnome/sources/file-roller/2.6/file-roller-2.6.1.tar.gz]
-md5=68a1b645b2e44227f7aca604fd42f8d1
-sha256=21e68eeb291ab5a9f4d618f2985c16c26cdfeb0f0f37d3b88550446678dab30a
-
 [http://ftp.gnome.org/pub/GNOME/sources/file-roller/2.28/file-roller-2.28.0.tar.bz2]
 md5=dcb0c887d5d287a28ebb5c0ea69bedfa
 sha256=499fe835b297720f4e4054b4ab34a3fb619c3460c5da82b1519d9b86aa2f3ac2
 
+[http://ftp.gnome.org/pub/gnome/sources/file-roller/2.6/file-roller-2.6.1.tar.gz]
+md5=68a1b645b2e44227f7aca604fd42f8d1
+sha256=21e68eeb291ab5a9f4d618f2985c16c26cdfeb0f0f37d3b88550446678dab30a
+
 [ftp://ftp.gnu.org/gnu/findutils/findutils-4.2.29.tar.gz]
 md5=24e76434ca74ba3c2c6ad621eb64e1ff
 sha256=1a9ed8db0711f8419156e786b6aecd42dd05df29e53e380d8924e696f7071ae0
@@ -7790,6 +7790,10 @@ sha256=619d59b339e1be7687058460c105b8f2d4f00e6409e4450dee385e3086fdf6d7
 md5=c6c22c7f9feff81a15f5c8ece03b87c1
 sha256=619d59b339e1be7687058460c105b8f2d4f00e6409e4450dee385e3086fdf6d7
 
+[http://gecko-mediaplayer.googlecode.com/files/gecko-mediaplayer-0.9.8.tar.gz]
+md5=4df009d21b1a95c35c9adfdb6fbc96fe
+sha256=a51ebf00021b1d5d43837edebd0fb28d8f6d2626111c4c391e8b0f6515004aa1
+
 [http://www.geda.seul.org/devel/20050820/geda-20050820.tar.gz]
 md5=e8d903d84515cc518e545b6f2e3d7a9d
 sha256=8e46a48d581f8b835f305bb17ffbb7776d53b9214113524819e96be842f9db98
diff --git a/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome.manifest b/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome.manifest
new file mode 100644 (file)
index 0000000..a137546
--- /dev/null
@@ -0,0 +1,3 @@
+content ai-flash chrome/content/ xpcnativewrappers=yes
+
+overlay chrome://browser/content/browser.xul chrome://ai-flash/content/ai-flash.xul
diff --git a/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.js b/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.js
new file mode 100644 (file)
index 0000000..c21ad58
--- /dev/null
@@ -0,0 +1,360 @@
+
+window.addEventListener("load", function() { myExtension.init(); }, false);
+
+var myExtension = {
+       init: function() {
+               var appcontent = document.getElementById("appcontent");   // browser
+               if(appcontent)
+                       appcontent.addEventListener("DOMContentLoaded", myExtension.onPageLoad, true);
+               var messagepane = document.getElementById("messagepane"); // mail
+               if(messagepane)
+                       messagepane.addEventListener("load", function () { myExtension.onPageLoad(); }, true);
+       },
+       
+       onPageLoad: function(aEvent) {
+               checkPageOnLoad(aEvent);
+       }
+}
+
+
+       var idInterval=-1;
+var stUrl = "";
+var timeout=2000;
+
+var width = 0;
+var height = 0;
+
+function rev(str) {
+       if(!str)
+               return'';
+       var revstr='';
+       for(i=str.length-1;i>=0;i--) {
+               revstr+=str.charAt(i);
+       }
+       return revstr;
+}
+
+function getDocuments(aFrame,aArray) {
+        const frames = aFrame.frames;
+        aArray.push(aFrame.document);
+        for(var i = 0; i < frames.length; i++)
+               this.getDocuments(frames[i],aArray);
+        return aArray;
+}
+
+function getBrowserForDocument(aDocument) {
+        // This function can return the browser for not only top level documents
+        // but also documents contained in subframes
+       
+        // If the document is top level then return its browser here
+        var browsers = gBrowser.browsers;
+        for(var i = 0; i < browsers.length; i++) {
+               if(aDocument == browsers[i].contentDocument) return browsers[i];
+        }
+       
+        // Else it must be in a subframe, so check all frames in each browser
+        // to find the parent browser
+        var documents;
+        for(var j = 0; j < browsers.length; j++) {
+               documents = this.getDocuments(browsers[j].contentWindow,new Array());
+               for(var k = 0; k < documents.length; k++) {
+                       if(aDocument == documents[k]) return browsers[j];
+               }
+        }
+       
+        // Else the browser could not be determined
+        return null;
+}
+
+function checkPageOnLoad(aEvent) {
+
+        var doc=aEvent.originalTarget;
+       var loc=doc.location.href;
+       var host=doc.location.hostname;
+       idInterval=-1;
+
+       if (host.match(/video.google\./i)!=null) {
+               // Get the browser for the document (if required)
+          
+               var browser = this.getBrowserForDocument(doc);
+               if(!browser){
+                       return;
+               }
+
+               embmedia=doc.getElementById("embed_player_1");
+               if ((embmedia!=null)&&(idInterval==-1)) {
+               
+                       // Extract video URL (look at clive code in parse.py for probably stabler code)
+                       source=unescape(embmedia.getAttribute('src'));
+                       stUrl=source.substr(source.indexOf('videoUrl=')+9);
+                       stUrl=stUrl.split("&thumbnailUrl=")[0];
+                       idInterval = setInterval(replaceTag, timeout, doc, "embed_player_1", new Array(embmedia));
+
+                       return;
+               }
+
+               setTimeout(checkPageOnLoad, timeout,aEvent);
+       }
+
+       if (host.match(/youtube\./i)!=null) {
+               embmedia=doc.embeds;
+               if ((embmedia!=null)&&(idInterval==-1)) {
+                       embid=embmedia[0].getAttribute('id');
+                       flashvars=unescape(embmedia[0].getAttribute('flashvars'));
+                       if ((embid==null)||(flashvars==null)){
+                               setTimeout(checkPageOnLoad,timeout,aEvent);
+                               return;
+                       }
+
+                       if ((embid=='movie_player')||(flashvars.match(/video_id=/i)!=null)) {
+                               id = flashvars.split("video_id=")[1].split("&")[0];
+                               valid = flashvars.split("&t=")[1].split("&")[0];
+                               stUrl = "http://www.youtube.com/get_video?video_id="+id+"&t="+valid;//&"&fmt=18"; for quality control
+                               idInterval = setInterval(replaceTag, timeout, doc, "movie_player", embmedia);                       
+                       }
+                                             
+               }
+               setTimeout(checkPageOnLoad,timeout,aEvent);
+       }
+
+       if (host.match(/myspace\./i)!=null) {
+
+               embmedia=doc.embeds;
+               if ((embmedia!=null)&&(idInterval==-1)) {
+                   
+                       // Myspace loves embedded flash ads, so we have to find the good one for the video...
+                       for(i=0;i<embmedia.length;i++){
+                               source=unescape(embmedia[i].getAttribute('src'));
+                               if (source==null){
+                                       return;
+                               }else{
+                                       id=-1;
+                                       if(source.match(/videoid=/i)!=null){
+                                               // regular video
+                                               id = (source.split("videoid=")[1]).split("&")[0];
+                                       }else if (source.match(/m=/i)!=null){
+                                               // video channels myspace or hot stuff
+                                               id = (source.split("m=")[1]).split("&")[0].split(",")[0];                               
+                                       }
+                           
+                                       if(id!=-1){
+                                               stUrl=getMySpaceURL(doc, id);
+                                               idInterval = setInterval(replaceTag, timeout, doc, " ", new Array(embmedia[i]));
+                                               return;
+                                       }
+                               }
+                       }
+               }
+
+       }
+       
+       if (host.match(/video.yahoo\./i)!=null) {
+               embmedia=doc.embeds;
+               if ((embmedia!=null)&&(idInterval==-1)) {
+                       for(i=0;i<embmedia.length;i++){
+                               embid = embmedia[i].getAttribute('id');
+                               if(embid=="video1"){
+                                       stUrl = getURLfromKeepVid(loc);
+                                       if (stUrl != null){
+                                               this.replaceTag(doc, embid, new Array(embmedia[i]));
+                                               return;
+                                       }
+                               }
+                       }
+               }
+               setTimeout(checkPageOnLoad,timeout,aEvent);                         
+               return;
+       }
+
+       if (host.match(/video.yahoo\./i)!=null) {
+               embmedia=doc.embeds;
+               if ((embmedia!=null)&&(idInterval==-1)) {
+                       for(i=0;i<embmedia.length;i++){
+                               embid = embmedia[i].getAttribute('id');
+                               if(embid=="video1"){
+                                       stUrl = getURLfromKeepVid(loc);
+                                       if (stUrl != null){
+                                               this.replaceTag(doc, embid, new Array(embmedia[i]));
+                                               return;
+                                       }
+                               }
+                       }
+               }
+               setTimeout(checkPageOnLoad,timeout,aEvent);                         
+               return;
+       }
+       
+       
+
+       //if (loc.match(/my\.yahoo\..*\/\?rd\=nux/i)!=null) {
+       //       atag=doc.getElementsByTagName('a');
+               //        for (i=0;i<atag.length;++i) {
+       //              if (atag[i].text.match(/Continue to My Yahoo! Beta/i)) {
+       //                      url = atag[i].href;
+       //                      doc.location.href = url;
+       //              }
+       //      }
+       //}
+
+       if (host.match(/dailymotion\./i)!=null) {
+        
+               embmedia=doc.embeds;
+               if ((embmedia!=null)&&(idInterval==-1)) {
+                       embid=embmedia[0].getAttribute('id');
+
+                       // regular video
+                       if (embid=='videoplayer') {
+                               // current player
+                               source='&'+unescape(embmedia[0].getAttribute('flashvars'));
+                               stUrl=source.substr(source.indexOf("http://www.dailymotion.com/cdn/H264-512x384"));
+                               stUrl=stUrl.split("@@")[0];
+                               idInterval = setInterval(replaceTag, timeout, doc, "videoplayer", embmedia);
+                       }
+               }
+               setTimeout(checkPageOnLoad,timeout,aEvent);
+       }
+}
+
+
+
+function replaceTagFrame(doc, frame, stTag) {
+       replaceTag(doc, stTag, frame.document.embeds);
+}
+
+
+function replaceTag(doc, stTag, embeds) {
+       for (i=0; i < embeds.length; i++) {
+               if ((stTag == " ")||(embeds[i].id == stTag)) {
+                       var obj = embeds[i];
+                       if (obj.id != "pconrails") {
+                               var rails = doc.createElement("embed");
+                               rails.setAttribute("type", "video/x-flv");
+                               rails.setAttribute("id", "pconrails");
+                               rails.setAttribute("width", obj.clientWidth);
+                               rails.setAttribute("height", obj.clientHeight);
+                               rails.setAttribute("src", stUrl);
+                               rails.setAttribute("autostart", "true");
+                               doc.body.appendChild(rails);
+                               obj.parentNode.replaceChild(rails, obj);
+                               clearInterval(idInterval);
+                       }
+               }
+       }
+}
+
+
+function getURLfromKeepVid(loc){
+        if(loc.match(/watch\//i)!=null){
+               url = escape(loc);
+               while (url.match("/")){
+                       url = url.replace("/","%2F"); 
+               }
+               url = "http://keepvid.com/?url="+url;
+
+               var req = new XMLHttpRequest();
+               req.open('GET', url, false);
+               req.send(null);
+           
+               var res = req.responseText;
+
+               /* should better parse DOM tree, but first have to build it, and this code does not work...
+                  var dom = document.createElement('div');
+                  dom.innerHTML = res.replace(/<script(.|\s)*?\/script>/g, '');
+                  alert(dom+"    "+dom.innerHTML);
+                  atag = dom.getElementsByTagName("h2");
+                  alert("atag.length="+atag.length+" atag="+atag);
+                  for (i=0;i<atag.length;i++) {
+                  alert("atag["+i+"]= "+atag[i]);
+                  if (atag[i].text.match(">> Download <<")) {
+                   
+                  return atag[i].href;
+                  }
+                  }
+               */
+               // ... so we parse the HTML instead
+               matchString = "&rsaquo;&rsaquo; Download &lsaquo;&lsaquo;";
+               if (res.match(matchString)){
+                       indexEnd = res.indexOf(matchString)-1;
+                       indexStart = 0;
+                       tag = "<a href=\"";
+                       var url = res;
+                       while(url.match(tag)){
+                               indexStart = url.indexOf(tag)+tag.length;
+                               url = url.substring(indexStart,indexEnd);
+                               indexEnd -= indexStart;
+                       }
+                       url = url.split("\"")[0];
+                       while(url.match("&amp;")){
+                               url = url.replace("&amp;","&");
+                       }
+                       return url;
+               }
+           
+       }
+       return null;
+}
+
+function getMySpaceURL(doc, id) {
+       url = 'http://mediaservices.myspace.com/services/rss.ashx?type=video&videoID=' + id; 
+
+       var req = new XMLHttpRequest();
+       req.open('GET', url, false);
+       req.send(null);
+
+       var xml = req.responseText;
+       return xml.split('media:content url="')[1].split('"')[0];
+}      
+
+function getFeaturedYouTubeURL(doc, id) {
+       var url = "http://www.youtube.com/watch?v=" + id;
+
+       var req = new XMLHttpRequest();
+       req.open('GET', url, false);
+       req.send(null);
+
+       var html = req.responseText;
+
+       source=html.match(/video_id=\S+&.+&t=.+&f/i);
+       return String(source).replace(/(video_id=\S+)&.+(&t=.+)&f/i,'http:\/\/www.youtube.com\/get_video?$1$2');
+}
+
+function replaceInnerHTML_Yahoo(doc) {
+       var obj = doc.getElementById("y_embed");
+
+       if (obj == null)
+               return;
+
+       var src = obj.innerHTML;
+
+       if (src.indexOf("makeplaylist.dll") != -1) {
+               var indexStart = obj.innerHTML.indexOf("pList=")+6;
+               var indexEnd = obj.innerHTML.indexOf("&", indexStart);
+
+               var newSrc = unescape(obj.innerHTML.substring(indexStart, indexEnd));
+
+               var req = new XMLHttpRequest();
+               req.open('GET', newSrc, false);
+               req.send(null);
+               
+               var newEmbed = req.responseText;
+
+               newEmbed = newEmbed.replace(/application\/x\-shockwave\-flash/, "video/x-flv");
+
+               indexStart = newEmbed.indexOf("<EMBED");
+               indexEnd = newEmbed.indexOf("</EMBED>")+8;
+
+               newHTML = newEmbed.substring(indexStart, indexEnd);
+
+               if (width != 0) {
+                       newHTML = newHTML.replace(/width=(\S+)\s/i, "width=" + width + " ");
+               }
+               if (height != 0) {                      
+                       newHTML = newHTML.replace(/height=(\S+)\s/i, "height=" + height + " ");
+               }
+
+               obj.innerHTML = newHTML;
+               clearInterval(idInterval);
+       }
+}
+
+
diff --git a/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.xul b/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.xul
new file mode 100644 (file)
index 0000000..82ba0d6
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+
+<overlay id="hijackpluginOverlay"
+               xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 
+
+<window id="main-window">
+ <script type="text/javascript" src="./ai-flash.js"/>
+</window>
+
+</overlay>
diff --git a/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/install.rdf b/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/install.rdf
new file mode 100644 (file)
index 0000000..dc99151
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>flash@alwaysinnovating.com</em:id>
+    <em:version>1.1</em:version>
+    <em:type>2</em:type>
+
+    <!-- Firefox -->
+    <em:targetApplication>
+      <Description>
+        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+         <em:minVersion>0.9</em:minVersion>
+         <em:maxVersion>3.9</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+    <em:name>Always Innovating Fix for Flash</em:name>
+    <em:description>Don't uninstall this add-on.</em:description>
+    <em:creator>Always Innovating</em:creator>
+    <em:contributor>Gregoire Gentil</em:contributor>
+    <em:homepageURL>http://www.alwaysinnovating.com</em:homepageURL>
+    <em:iconURL></em:iconURL>
+    <em:optionsURL></em:optionsURL>
+  </Description>
+</RDF> 
diff --git a/recipes/gnome-mplayer/gecko-mediaplayer_0.9.8.bb b/recipes/gnome-mplayer/gecko-mediaplayer_0.9.8.bb
new file mode 100644 (file)
index 0000000..7035f41
--- /dev/null
@@ -0,0 +1,33 @@
+DESCRIPTION = "Gecko plugin for gnome-mplayer"
+HOMEPAGE = "http://dekorte.homeip.net/download/gecko-mediaplayer/"
+LICENSE = "GPL"
+DEPENDS = "firefox gtk+ gconf dbus-glib"
+RDEPENDS = "firefox gnome-mplayer"
+
+inherit autotools
+
+SRC_URI = "http://gecko-mediaplayer.googlecode.com/files/${P}.tar.gz \
+           file://extensions \
+"
+
+# Yes, this needs to match the firefox version you are building *exactly*
+MOZILLA_HOME = firefox-3.5.2
+
+do_install_append() {
+       install -d  ${D}${libdir}/${MOZILLA_HOME}
+       mv ${D}${libdir}/mozilla/plugins ${D}${libdir}/${MOZILLA_HOME}
+       cp -dpR ${WORKDIR}/extens* ${D}${libdir}/${MOZILLA_HOME}/
+}
+
+
+#EXTRA_OEMAKE = "-I${STAGING_INCDIR}/${MOZILLA_HOME} -I${STAGING_INCDIR}/linux"
+
+PACKAGES =+ "${PN}-firefox-hack"
+RDEPENDS_${PN}-firefox-hack = "${PN}"
+FILES_${PN}-firefox-hack = "${D}${libdir}/${MOZILLA_HOME}/extensions"
+
+FILES_${PN} += "${sysconfdir}/* \
+                ${libdir}/${MOZILLA_HOME}/*"
+FILES_${PN}-dbg += "${libdir}/${MOZILLA_HOME}/plugins/.debug/*"
+
+