From 5a301f4df7463cef7fe3797f807d1da1914fb4de Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Thu, 1 Oct 2009 12:16:12 +0200 Subject: gecko-mplayer: import from AlwaysInnovating overlay and clean it up a bit --- .../flash@alwaysinnovating.com/chrome.manifest | 3 + .../chrome/content/ai-flash.js | 360 +++++++++++++++++++++ .../chrome/content/ai-flash.xul | 10 + .../flash@alwaysinnovating.com/install.rdf | 27 ++ recipes/gnome-mplayer/gecko-mediaplayer_0.9.8.bb | 33 ++ 5 files changed, 433 insertions(+) create mode 100644 recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome.manifest create mode 100644 recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.js create mode 100644 recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.xul create mode 100644 recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/install.rdf create mode 100644 recipes/gnome-mplayer/gecko-mediaplayer_0.9.8.bb (limited to 'recipes/gnome-mplayer') 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 index 0000000000..a137546bf7 --- /dev/null +++ b/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome.manifest @@ -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 index 0000000000..c21ad58847 --- /dev/null +++ b/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.js @@ -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/g, ''); + alert(dom+" "+dom.innerHTML); + atag = dom.getElementsByTagName("h2"); + alert("atag.length="+atag.length+" atag="+atag); + for (i=0;i> Download <<")) { + + return atag[i].href; + } + } + */ + // ... so we parse the HTML instead + matchString = "›› Download ‹‹"; + if (res.match(matchString)){ + indexEnd = res.indexOf(matchString)-1; + indexStart = 0; + tag = "")+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 index 0000000000..82ba0d6d5a --- /dev/null +++ b/recipes/gnome-mplayer/gecko-mediaplayer/extensions/flash@alwaysinnovating.com/chrome/content/ai-flash.xul @@ -0,0 +1,10 @@ + + + + + +