diff options
author | trapezoid | 2008-04-03 01:59:32 +0000 |
---|---|---|
committer | trapezoid | 2008-04-03 01:59:32 +0000 |
commit | 31ed477450f55042d3e88e13b4a44904ac07668b (patch) | |
tree | 5b562dc15f34f64fbc557503d09a7fd540ec0ffb /ldrize_cooperation_fetch_flv.js | |
parent | bf224a143dbef3f1ec586c330eae587e43162320 (diff) | |
download | vimperator-plugins-31ed477450f55042d3e88e13b4a44904ac07668b.tar.bz2 |
lang/javascript/vimperator-plugins/trunk/ldrize_cooperation.js, ldrize_cooperation_fetch_flv.js: add loading plugins future
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@8715 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'ldrize_cooperation_fetch_flv.js')
-rwxr-xr-x | ldrize_cooperation_fetch_flv.js | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/ldrize_cooperation_fetch_flv.js b/ldrize_cooperation_fetch_flv.js index ae7a418..9e3c545 100755 --- a/ldrize_cooperation_fetch_flv.js +++ b/ldrize_cooperation_fetch_flv.js @@ -1,58 +1,53 @@ // Vimperator plugin: 'Cooperation LDRize Mappings - Niconico Flv Fetcher'
-// Version: 0.1
+// Version: 0.2
// Last Change: 03-Apr-2008. Jan 2008
// License: Creative Commons
// Maintainer: Trapezoid <trapezoid.g@gmail.com> - http://unsigned.g.hatena.ne.jp/Trapezoid
//
// Cooperation LDRize Mappings - Niconico Flv Fetcher for vimperator0.6.*
-//
+// Require LDRize Cooperation ver 0.13
(function(){
- function LDRizeCooperationNiconicoFlvFetcher(LDRizeCooperation){
- var NiconicoFlvFetcher = [
- {
- pattern: 'http://www.nicovideo.jp/watch/*',
- handler: function(url,title){
- const nicoApiEndPoint = "http://www.nicovideo.jp/api/getflv?v=";
- const nicoWatchEndPoint = "http://www.nicovideo.jp/watch/";
- var videoId = url.match(/\wm\d+/)[0];
- httpGET(nicoApiEndPoint + videoId,function(apiResult){
- var flvUrl = decodeURIComponent(apiResult.match(/url=(.*?)&/)[1]);
+ function LDRizeCooperationNiconicoFlvFetcher(){
+ var NiconicoFlvFetcher = {
+ pattern: 'http://www.nicovideo.jp/watch/*',
+ handler: function(url,title){
+ const nicoApiEndPoint = "http://www.nicovideo.jp/api/getflv?v=";
+ const nicoWatchEndPoint = "http://www.nicovideo.jp/watch/";
+ var videoId = url.match(/\wm\d+/)[0];
+ httpGET(nicoApiEndPoint + videoId,function(apiResult){
+ var flvUrl = decodeURIComponent(apiResult.match(/url=(.*?)&/)[1]);
- httpGET(nicoWatchEndPoint + videoId,function(watchPage){
- try{
- var DownloadManager = Cc["@mozilla.org/download-manager;1"]
- .getService(Ci.nsIDownloadManager);
- var WebBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
- .createInstance(Ci.nsIWebBrowserPersist);
+ httpGET(nicoWatchEndPoint + videoId,function(watchPage){
+ try{
+ var DownloadManager = Cc["@mozilla.org/download-manager;1"]
+ .getService(Ci.nsIDownloadManager);
+ var WebBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Ci.nsIWebBrowserPersist);
- var sourceUri = makeURI(flvUrl,null,null);
- var file = DownloadManager.userDownloadsDirectory;
- file.appendRelativePath(title + ".flv");
- var fileUri = makeFileURI(file);
+ var sourceUri = makeURI(flvUrl,null,null);
+ var file = DownloadManager.userDownloadsDirectory;
+ file.appendRelativePath(title + ".flv");
+ var fileUri = makeFileURI(file);
- var download = DownloadManager.addDownload(0, sourceUri, fileUri, title + ".flv",
- null, null, null, null, WebBrowserPersist);
- WebBrowserPersist.progressListener = download;
- WebBrowserPersist.saveURI(sourceUri, null, null, null, null, file);
- }catch(e){log(e);liberator.echoerr(e)}
- });
+ var download = DownloadManager.addDownload(0, sourceUri, fileUri, title + ".flv",
+ null, null, null, null, WebBrowserPersist);
+ WebBrowserPersist.progressListener = download;
+ WebBrowserPersist.saveURI(sourceUri, null, null, null, null, file);
+ }catch(e){log(e);liberator.echoerr(e)}
});
- },
- wait: 5000
- }
- ]
- LDRizeCooperation.convertHandlerInfo(NiconicoFlvFetcher);
- LDRizeCooperation.handlerInfo.unshift(NiconicoFlvFetcher[0]);
+ });
+ },
+ wait: 5000
+ }
+ this.convertHandlerInfo([NiconicoFlvFetcher]);
+ this.handlerInfo.unshift(NiconicoFlvFetcher);
}
if(liberator.plugins.LDRizeCooperation == undefined){
- liberator.plugins.watch('LDRizeCooperation',function(id,oldValue,newValue){
- liberator.plugins.unwatch('LDRizeCooperation');
- LDRizeCooperationNiconicoFlvFetcher(newValue);
- return newValue;
- });
+ liberator.plugins.LDRizeCooperationPlugins = liberator.plugins.LDRizeCooperationPlugins || [];
+ liberator.plugins.LDRizeCooperationPlugins.push(LDRizeCooperationNiconicoFlvFetcher);
}else{
- LDRizeCooperationNiconicoFlvFetcher(liberator.plugins.LDRizeCooperation);
+ LDRizeCooperationNiconicoFlvFetcher.apply(liberator.plugins.LDRizeCooperation);
}
function httpGET(uri,callback){
|