Changeset 8715

Show
Ignore:
Timestamp:
04/03/08 10:59:32 (5 years ago)
Author:
trapezoid
Message:

lang/javascript/vimperator-plugins/trunk/ldrize_cooperation.js, ldrize_cooperation_fetch_flv.js: add loading plugins future

Location:
lang/javascript/vimperator-plugins/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/vimperator-plugins/trunk/ldrize_cooperation.js

    r8690 r8715  
    11// Vimperator plugin: 'Cooperation LDRize Mappings' 
    2 // Version: 0.13 
     2// Version: 0.14 
    33// Last Change: 03-Apr-2008. Jan 2008 
    44// License: Creative Commons 
     
    103103            this.initLDRizeCooperationFuture(); 
    104104            this.setupStatusbarPanel(); 
     105 
     106            if(liberator.plugins.LDRizeCooperationPlugins != undefined){ 
     107                liberator.plugins.LDRizeCooperationPlugins.forEach(function(func){ 
     108                    func.apply(self,arguments); 
     109                }); 
     110                delete liberator.plugins.LDRizeCooperationPlugins; 
     111            } 
    105112        }, 
    106113        setupStatusbarPanel: function(){ 
  • lang/javascript/vimperator-plugins/trunk/ldrize_cooperation_fetch_flv.js

    r8690 r8715  
    11// Vimperator plugin: 'Cooperation LDRize Mappings - Niconico Flv Fetcher' 
    2 // Version: 0.1 
     2// Version: 0.2 
    33// Last Change: 03-Apr-2008. Jan 2008 
    44// License: Creative Commons 
     
    66// 
    77// Cooperation LDRize Mappings - Niconico Flv Fetcher for vimperator0.6.* 
    8 // 
     8// Require LDRize Cooperation ver 0.13 
    99(function(){ 
    10     function LDRizeCooperationNiconicoFlvFetcher(LDRizeCooperation){ 
    11         var NiconicoFlvFetcher = [ 
    12             { 
    13                 pattern: 'http://www.nicovideo.jp/watch/*', 
    14                 handler: function(url,title){ 
    15                     const nicoApiEndPoint = "http://www.nicovideo.jp/api/getflv?v="; 
    16                     const nicoWatchEndPoint = "http://www.nicovideo.jp/watch/"; 
    17                     var videoId = url.match(/\wm\d+/)[0]; 
    18                     httpGET(nicoApiEndPoint + videoId,function(apiResult){ 
    19                         var flvUrl = decodeURIComponent(apiResult.match(/url=(.*?)&/)[1]); 
     10    function LDRizeCooperationNiconicoFlvFetcher(){ 
     11        var NiconicoFlvFetcher = { 
     12            pattern: 'http://www.nicovideo.jp/watch/*', 
     13            handler: function(url,title){ 
     14                const nicoApiEndPoint = "http://www.nicovideo.jp/api/getflv?v="; 
     15                const nicoWatchEndPoint = "http://www.nicovideo.jp/watch/"; 
     16                var videoId = url.match(/\wm\d+/)[0]; 
     17                httpGET(nicoApiEndPoint + videoId,function(apiResult){ 
     18                    var flvUrl = decodeURIComponent(apiResult.match(/url=(.*?)&/)[1]); 
    2019 
    21                         httpGET(nicoWatchEndPoint + videoId,function(watchPage){ 
    22                             try{ 
    23                                 var DownloadManager = Cc["@mozilla.org/download-manager;1"] 
    24                                     .getService(Ci.nsIDownloadManager); 
    25                                 var WebBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] 
    26                                     .createInstance(Ci.nsIWebBrowserPersist); 
     20                    httpGET(nicoWatchEndPoint + videoId,function(watchPage){ 
     21                        try{ 
     22                            var DownloadManager = Cc["@mozilla.org/download-manager;1"] 
     23                                .getService(Ci.nsIDownloadManager); 
     24                            var WebBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] 
     25                                .createInstance(Ci.nsIWebBrowserPersist); 
    2726 
    28                                 var sourceUri = makeURI(flvUrl,null,null); 
    29                                 var file = DownloadManager.userDownloadsDirectory; 
    30                                 file.appendRelativePath(title + ".flv"); 
    31                                 var fileUri = makeFileURI(file); 
     27                            var sourceUri = makeURI(flvUrl,null,null); 
     28                            var file = DownloadManager.userDownloadsDirectory; 
     29                            file.appendRelativePath(title + ".flv"); 
     30                            var fileUri = makeFileURI(file); 
    3231 
    33                                 var download = DownloadManager.addDownload(0, sourceUri, fileUri, title + ".flv", 
    34                                         null, null, null, null, WebBrowserPersist); 
    35                                 WebBrowserPersist.progressListener = download; 
    36                                 WebBrowserPersist.saveURI(sourceUri, null, null, null, null, file); 
    37                             }catch(e){log(e);liberator.echoerr(e)} 
    38                         }); 
     32                            var download = DownloadManager.addDownload(0, sourceUri, fileUri, title + ".flv", 
     33                                    null, null, null, null, WebBrowserPersist); 
     34                            WebBrowserPersist.progressListener = download; 
     35                            WebBrowserPersist.saveURI(sourceUri, null, null, null, null, file); 
     36                        }catch(e){log(e);liberator.echoerr(e)} 
    3937                    }); 
    40                 }, 
    41                 wait: 5000 
    42             } 
    43         ] 
    44         LDRizeCooperation.convertHandlerInfo(NiconicoFlvFetcher); 
    45         LDRizeCooperation.handlerInfo.unshift(NiconicoFlvFetcher[0]); 
     38                }); 
     39            }, 
     40            wait: 5000 
     41        } 
     42        this.convertHandlerInfo([NiconicoFlvFetcher]); 
     43        this.handlerInfo.unshift(NiconicoFlvFetcher); 
    4644    } 
    4745 
    4846    if(liberator.plugins.LDRizeCooperation == undefined){ 
    49         liberator.plugins.watch('LDRizeCooperation',function(id,oldValue,newValue){ 
    50             liberator.plugins.unwatch('LDRizeCooperation'); 
    51             LDRizeCooperationNiconicoFlvFetcher(newValue); 
    52             return newValue; 
    53         }); 
     47        liberator.plugins.LDRizeCooperationPlugins = liberator.plugins.LDRizeCooperationPlugins || []; 
     48        liberator.plugins.LDRizeCooperationPlugins.push(LDRizeCooperationNiconicoFlvFetcher); 
    5449    }else{ 
    55         LDRizeCooperationNiconicoFlvFetcher(liberator.plugins.LDRizeCooperation); 
     50        LDRizeCooperationNiconicoFlvFetcher.apply(liberator.plugins.LDRizeCooperation); 
    5651    } 
    5752