PK V8chrome/PK V8chrome/content/PK %'7>bchrome/content/io.js///////////////////////////////////////////////// ///////////////////////////////////////////////// // // Basic JavaScript File and Directory IO module // By: MonkeeSage, v0.1 // ///////////////////////////////////////////////// ///////////////////////////////////////////////// if (typeof(JSIO) != 'boolean') { var JSIO = true; ///////////////////////////////////////////////// // Basic file IO object based on Mozilla source // code post at forums.mozillazine.org ///////////////////////////////////////////////// // Example use: // var fileIn = FileIO.open('/test.txt'); // if (fileIn.exists()) { // var fileOut = FileIO.open('/copy of test.txt'); // var str = FileIO.read(fileIn); // var rv = FileIO.write(fileOut, str); // alert('File write: ' + rv); // rv = FileIO.write(fileOut, str, 'a'); // alert('File append: ' + rv); // rv = FileIO.unlink(fileOut); // alert('File unlink: ' + rv); // } var FileIO = { localfileCID : '@mozilla.org/file/local;1', localfileIID : Components.interfaces.nsILocalFile, finstreamCID : '@mozilla.org/network/file-input-stream;1', finstreamIID : Components.interfaces.nsIFileInputStream, foutstreamCID : '@mozilla.org/network/file-output-stream;1', foutstreamIID : Components.interfaces.nsIFileOutputStream, sinstreamCID : '@mozilla.org/scriptableinputstream;1', sinstreamIID : Components.interfaces.nsIScriptableInputStream, suniconvCID : '@mozilla.org/intl/scriptableunicodeconverter', suniconvIID : Components.interfaces.nsIScriptableUnicodeConverter, open : function(path) { try { var file = Components.classes[this.localfileCID] .createInstance(this.localfileIID); file.initWithPath(path); return file; } catch(e) { return false; } }, read : function(file, charset) { try { var data = new String(); var fiStream = Components.classes[this.finstreamCID] .createInstance(this.finstreamIID); var siStream = Components.classes[this.sinstreamCID] .createInstance(this.sinstreamIID); fiStream.init(file, 1, 0, false); siStream.init(fiStream); data += siStream.read(-1); siStream.close(); fiStream.close(); if (charset) { data = this.toUnicode(charset, data); } return data; } catch(e) { return false; } }, write : function(file, data, mode, charset) { try { var foStream = Components.classes[this.foutstreamCID] .createInstance(this.foutstreamIID); if (charset) { data = this.fromUnicode(charset, data); } var flags = 0x02 | 0x08 | 0x20; // wronly | create | truncate if (mode == 'a') { flags = 0x02 | 0x10; // wronly | append } foStream.init(file, flags, 0664, 0); foStream.write(data, data.length); // foStream.flush(); foStream.close(); return true; } catch(e) { return false; } }, create : function(file) { try { file.create(0x00, 0664); return true; } catch(e) { return false; } }, unlink : function(file) { try { file.remove(false); return true; } catch(e) { return false; } }, path : function(file) { try { return 'file:///' + file.path.replace(/\\/g, '\/') .replace(/^\s*\/?/, '').replace(/\ /g, '%20'); } catch(e) { return false; } }, toUnicode : function(charset, data) { try{ var uniConv = Components.classes[this.suniconvCID] .createInstance(this.suniconvIID); uniConv.charset = charset; data = uniConv.ConvertToUnicode(data); } catch(e) { // foobar! } return data; }, fromUnicode : function(charset, data) { try { var uniConv = Components.classes[this.suniconvCID] .createInstance(this.suniconvIID); uniConv.charset = charset; data = uniConv.ConvertFromUnicode(data); // data += uniConv.Finish(); } catch(e) { // foobar! } return data; } } ///////////////////////////////////////////////// // Basic Directory IO object based on JSLib // source code found at jslib.mozdev.org ///////////////////////////////////////////////// // Example use: // var dir = DirIO.open('/test'); // if (dir.exists()) { // alert(DirIO.path(dir)); // var arr = DirIO.read(dir, true), i; // if (arr) { // for (i = 0; i < arr.length; ++i) { // alert(arr[i].path); // } // } // } // else { // var rv = DirIO.create(dir); // alert('Directory create: ' + rv); // } // --------------------------------------------- // ----------------- Nota Bene ----------------- // --------------------------------------------- // Some possible types for get are: // 'ProfD' = profile // 'DefProfRt' = user (e.g., /root/.mozilla) // 'UChrm' = %profile%/chrome // 'DefRt' = installation // 'PrfDef' = %installation%/defaults/pref // 'ProfDefNoLoc' = %installation%/defaults/profile // 'APlugns' = %installation%/plugins // 'AChrom' = %installation%/chrome // 'ComsD' = %installation%/components // 'CurProcD' = installation (usually) // 'Home' = OS root (e.g., /root) // 'TmpD' = OS tmp (e.g., /tmp) var DirIO = { sep : '/', dirservCID : '@mozilla.org/file/directory_service;1', propsIID : Components.interfaces.nsIProperties, fileIID : Components.interfaces.nsIFile, get : function(type) { try { var dir = Components.classes[this.dirservCID] .createInstance(this.propsIID) .get(type, this.fileIID); return dir; } catch(e) { return false; } }, open : function(path) { return FileIO.open(path); }, create : function(dir) { try { dir.create(0x01, 0664); return true; } catch(e) { return false; } }, read : function(dir, recursive) { var list = new Array(); try { if (dir.isDirectory()) { if (recursive == null) { recursive = false; } var files = dir.directoryEntries; list = this._read(files, recursive); } } catch(e) { // foobar! } return list; }, _read : function(dirEntry, recursive) { var list = new Array(); try { while (dirEntry.hasMoreElements()) { list.push(dirEntry.getNext() .QueryInterface(FileIO.localfileIID)); } if (recursive) { var list2 = new Array(); for (var i = 0; i < list.length; ++i) { if (list[i].isDirectory()) { files = list[i].directoryEntries; list2 = this._read(files, recursive); } } for (i = 0; i < list2.length; ++i) { list.push(list2[i]); } } } catch(e) { // foobar! } return list; }, unlink : function(dir, recursive) { try { if (recursive == null) { recursive = false; } dir.remove(recursive); return true; } catch(e) { return false; } }, path : function (dir) { return FileIO.path(dir); }, split : function(str, join) { var arr = str.split(/\/|\\/), i; str = new String(); for (i = 0; i < arr.length; ++i) { str += arr[i] + ((i != arr.length - 1) ? join : ''); } return str; }, join : function(str, split) { var arr = str.split(split), i; str = new String(); for (i = 0; i < arr.length; ++i) { str += arr[i] + ((i != arr.length - 1) ? this.sep : ''); } return str; } } if (navigator.platform.toLowerCase().indexOf('win') > -1) { DirIO.sep = '\\'; } } PK B8[ 99chrome/content/loader.gifGIF89aFFFzzzXXX$$$666hhh! NETSCAPE2.0!Created with ajaxload.info! ,w  !DBAH¬aD@ ^AXP@"UQ# B\; 1 o:2$v@ $|,3 _# d53" s5 e!! ,v i@e9DAA/`ph$Ca%@ pHxFuSx# .݄YfL_" p 3BW ]|L \6{|z87[7!! ,x  e9DE"2r,qPj`8@8bH, *0- mFW9LPE3+ (B"  f{*BW_/ @_$~Kr7Ar7!! ,v 4e9!H"* Q/@-4ép4R+-pȧ`P(6᠝U/  *,)(+/]"lO/*Ak K]A~666!! ,l ie9"* -80H=N; TEqe UoK2_WZ݌V1jgWe@tuH//w`?f~#6#!! ,~ ,e9"* ; pR%#0` 'c(J@@/1i4`VBV u}"caNi/ ] ))-Lel  mi} me[+!! ,y Ie9"M6*¨"7E͖@G((L&pqj@Z %@wZ) pl( ԭqu*R&c `))( s_J>_\'Gm7$+!! ,w Ie9*, (*(B5[1 ZIah!GexzJ0e6@V|U4Dm%$͛p \Gx }@+| =+ 1- Ea5l)+!! ,y )䨞'AKڍ,E\(l&;5 5D03a0--ÃpH4V % i p[R"| #  6iZwcw*!! ,y )䨞,K*0 a;׋аY8b`4n ¨Bbbx,( Ƚ  % >  2*i* /:+$v*!! ,u )䨞l[$ Jq[q 3`Q[5:IX!0rAD8 CvHPfiiQAP@pC %D PQ46  iciNj0w )#!! ,y ). q ,G Jr(J8 C*B,&< h W~-`, ,>; 8RN<, <1T] c' qk$ @)#!;PK \P81xRTTchrome/content/options.xul //Flowplayer flash player preferences //JW flash player preferences PK qf8\ T&T&chrome/content/youtube.js /**javascript console***/ function LOG(msg) { var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService); consoleService.logStringMessage(msg); } // Get the "extensions.myext." branch var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); prefs = prefs.getBranch("extensions.youtubealternateplayer."); function iCanHazTubes(fv, vidID, pD, page, vidTitle, toReplace){ var getBod = page.getElementsByTagName('body')[0]; var srcWithT = 'http://'+page.domain+'/get_video?video_id='+vidID+'&t='+fv.split("t=")[1].split("&")[0]; function embedVID(respHead){ //bit dodgy but meh getBod.setAttribute('finalLink', respHead); var whichPlaya = "FlowPlayer"; var e = page.createElement('embed'); e.width = "480"; e.height = "395"; e.setAttribute('type', 'application/x-shockwave-flash'); e.allowscriptaccess = "always"; e.quality="high"; e.setAttribute('allowfullscreen','true'); var fVars = []; function setVars(key, value){ fVars.push(key+value); } if( prefs.getCharPref("flow.whichPlayer") == "JW"){ e.id = "mediaplayer"; e.setAttribute('name', "mediaplayer"); e.setAttribute('src', "http://gmflowplayer.googlecode.com/files/mediaplayeralt.swf"); //http://www.jeroenwijering.com/?item=Supported_Flashvars setVars('height=', '395'); setVars('width=', '480'); setVars('file=', respHead+'.flv'); setVars('image=', 'http://img.youtube.com/vi/'+vidID+'/default.jpg'); setVars('overstretch=', prefs.getBoolPref("JW.overstretch")); setVars('showdigits=', prefs.getBoolPref("JW.showdigits")); setVars('autostart=', prefs.getBoolPref("JW.autostart")); setVars('bufferlength=', prefs.getIntPref("JW.bufferlength")); setVars('repeat=', prefs.getBoolPref("JW.repeat")); setVars('volume=', prefs.getIntPref("JW.volume")); setVars('javascriptid=', 'mediaplayer'); setVars('autobuffer=', prefs.getBoolPref("JW.autoBuffering")); var fVJoined = fVars.join('&'); e.setAttribute('flashvars', fVJoined); pD.appendChild(e); } else if( prefs.getCharPref("flow.whichPlayer") == "flow"){ var pl; /*if(prefs.getBoolPref("flow.autoPlay")){ pl = "[{ url: '"+respHead+".flv'}]"; } else{ pl = "[ { url: 'http://img.youtube.com/vi/"+vidID+"/default.jpg', overlayId: 'play' }, { url: '"+respHead+".flv'}]"; }*/ e.id = "FlowPlayer"; e.name = "FlowPlayer"; e.setAttribute('src', "http://gmflowplayer.googlecode.com/files/FlowPlayerLatest.swf"); setVars('allowfullscreen:', prefs.getBoolPref("flow.allowfullscreen")); setVars('showPlayListButtons:', prefs.getBoolPref("flow.showPlayListButtons")); setVars('initialScale:', "'"+prefs.getCharPref('flow.initialScale')+"'"); setVars('showLoopButton:', prefs.getBoolPref("flow.showLoopButton")); setVars('allowResize:', prefs.getBoolPref("flow.allowResize")); setVars('useNativeFullScreen:', prefs.getBoolPref("flow.useNativeFullScreen")); setVars('autoBuffering:', prefs.getBoolPref("flow.autoBuffering")); setVars('autoPlay:', prefs.getBoolPref("flow.autoPlay")); setVars('loop:', prefs.getBoolPref("flow.loop")); setVars('usePlayOverlay:', prefs.getBoolPref("flow.usePlayOverlay")); setVars('splashImageFile:', '\'http://img.youtube.com/vi/'+vidID+'/default.jpg\''); setVars('videoFile:', "'"+respHead+"'"); setVars('scaleSplash:', prefs.getBoolPref("flow.scaleSplash")); setVars('bufferLength:', prefs.getIntPref("flow.bufferLength")); setVars('showStopButton:', prefs.getBoolPref("flow.showStopButton")); var fVJoined = fVars.join(','); e.setAttribute('flashvars', 'config={'+fVJoined+'}'); pD.appendChild(e); } else if( prefs.getCharPref("flow.whichPlayer") == "defaultEmbeded"){ var l = fv.slice( fv.indexOf('&l=')+3, fv.indexOf( '&', fv.indexOf('&l=')+3 ) ); var t = fv.slice( fv.indexOf('&t=')+3, fv.indexOf( '&', fv.indexOf('&t=')+3 ) ); pD.innerHTML = ''; } //I don't get it either, but it wont show up without a mini refresh. pD.innerHTML = pD.innerHTML; } /***Thanks to Sergei Zhirikov for the code ***/ // accepted HTTP status codes var redirect = {300: null, 301: null, 302: null, 303: null, 307: null}; var listener = { onStartRequest: function(request, context) {}, onStopRequest: function(request, context, status) { if (status == 0x804B001F) { // NS_ERROR_REDIRECT_LOOP var channel = request.QueryInterface(Components.interfaces.nsIHttpChannel); if (channel.responseStatus in redirect) { var respHead = null; try { respHead = channel.getResponseHeader('Location'); } catch (exc) { // no 'Location' header sent with the redirect; LOG('no Location header sent with the redirect '+exc); } if (respHead != null) { embedVID(encodeURIComponent(respHead)); } } } }, onDataAvailable: function(request, context, stream, offset, length) { // abort the request in case we didn't get redirected request.cancel(Components.results.NS_ERROR_UNEXPECTED); }, QueryInterface: function(iid) { if (iid.equals(Components.interfaces.nsISupports) || iid.equals(Components.interfaces.nsIStreamListener) || iid.equals(Components.interfaces.nsIRequestObserver)) { return this; } else { throw Components.results.NS_NOINTERFACE; } }, }; var channel = null, context = null; try { channel = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newChannel(srcWithT, null, null).QueryInterface(Components.interfaces.nsIHttpChannel) } catch (exc) { // something went wrong when creating a channel instance LOG('something went wrong when creating a channel instance '+exc); } if (channel) { channel.redirectionLimit = 0; channel.asyncOpen(listener, context); } } //end of: function icanhaztubes function runFromS(player){ var curBrow = getBrowser().selectedBrowser.contentDocument; var vidURL = decodeURIComponent(curBrow.evaluate( "//body" ,curBrow, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.getAttribute('finalLink')); var vTitle = curBrow.evaluate( "//div[@id='vidTitle']" ,curBrow, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.textContent; if(player == 'download'){ if ( typeof JSLoader == "undefined" ){ var JSLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader); JSLoader.loadSubScript("chrome://youtubealternateplayer/content/io.js"); } /*** Original Code by Wojciech Walewski. license - MPL 1.1/GPL 2.0/LGPL 2.1 (taken from the "youplayer" extension code) ... GPL FTW!! ***/ // open filepicker dialog var nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); fp.init(window, null, nsIFilePicker.modeSave); fp.appendFilter("Flash Video Files (*.flv)", "*.flv"); vTitle = vTitle.replace(/[^a-zA-Z0-9\.\-]/g, "_") + ".flv"; fp.defaultString = vTitle; fp.defaultExtension = "flv"; if(fp.show() == nsIFilePicker.returnCancel) return; var io_service = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var source_uri = io_service.newURI(vidURL, null, null); var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] .createInstance(Components.interfaces.nsIWebBrowserPersist); persist.persistFlags = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] .createInstance(Components.interfaces.nsIWebBrowserPersist).PERSIST_FLAGS_REPLACE_EXISTING_FILES; // save the movie to a file var transfer = Components.classes["@mozilla.org/transfer;1"] .createInstance(Components.interfaces.nsITransfer); transfer.init(source_uri, fp.fileURL, "", null, null, null, persist); persist.progressListener = transfer; persist.saveURI(source_uri, null, null, null, null, fp.file); /*** end Walewski code***/ } else if(player == 'restore'){ var getEmbeds; if(curBrow.URL.match('watch?')){ getEmbeds = curBrow.evaluate( "//div[@id='playerDiv']//embed", curBrow, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); } else if(curBrow.URL.match('/user/') ){ getEmbeds = curBrow.evaluate( "/html/body/div[@id='baseDiv']/div[3]/div[2]/div[1]/object//embed", curBrow, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); } for(var s = 0; s < getEmbeds.snapshotLength; s++){ var sEm = getEmbeds.snapshotItem(s); (sEm.style.display == 'none')? sEm.style.display = 'block': sEm.style.display = 'none'; } } } PK Q8_chrome/content/ypa.js /**javascript console***/ function LOG(msg) { var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService); consoleService.logStringMessage(msg); } function aPlaya(page){ var dUrl = page.URL; var vidID, vidTitle, toReplace, savedOriginal, pD; if ( typeof JSSubScriptLoader == "undefined" ){ var JSSubScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader); JSSubScriptLoader.loadSubScript("chrome://youtubealternateplayer/content/youtube.js"); } if(dUrl.match('watch?')){ toReplace = page.getElementById('movie_player'); var getwPlayerVars = toReplace.getAttribute('flashvars'); vidID = dUrl.split("v=")[1].split("&")[0]; pD = toReplace.parentNode; iCanHazTubes(getwPlayerVars, vidID, pD, page, vidTitle, toReplace); } else if( dUrl.match('/user/') ){ toReplace = page.evaluate( "/html/body/div[@id='baseDiv']/div[3]/div[2]/div[1]/object/embed", page, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; vidTitle = page.evaluate( "//div[@class='profileEmbedVideo']//div[@class='vtitle']" ,page, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.textContent; vidID = xE.src.split("video_id=")[1].split("&")[0]; pD = toReplace.parentNode; iCanHazTubes(toReplace.src, vidID, pD, page, vidTitle, toReplace); } toReplace.style.display = 'none'; } //end of: function aPlaya(page){ var appcontent = document.getElementById('appcontent'); if ( appcontent ){ appcontent.addEventListener("DOMContentLoaded", function (event) { if(event.target.URL.match('youtube.com')){ document.getElementById('youtubealt_panel').setAttribute('disabled', 'false'); document.getElementById('youtubealt_panel').style.opacity = "1"; aPlaya(event.target); } else{ document.getElementById('youtubealt_panel').setAttribute('disabled', 'true'); document.getElementById('youtubealt_panel').style.opacity = "0.4"; } }, false); } getBrowser().addEventListener("TabSelect", function (event) { if(event.target.contentDocument.URL.match("youtube.com")){ document.getElementById('youtubealt_panel').setAttribute('disabled', 'false'); document.getElementById('youtubealt_panel').style.opacity = "1"; } else{ document.getElementById('youtubealt_panel').setAttribute('disabled', 'true'); document.getElementById('youtubealt_panel').style.opacity = "0.4"; } }, false); /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ PK `:S8^Uchrome/content/yuotoverlay.xul