Changeset 5323 for lang/javascript

Show
Ignore:
Timestamp:
01/23/08 03:27:08 (5 years ago)
Author:
noriaki
Message:

lang/javascript/userscripts/niconicodougaanalytics.user.js: fiexed compatibility for the GreaseMonkey?-0.7.20080121.0. supported the flvplayer_wrapper.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/niconicodougaanalytics.user.js

    r5187 r5323  
    55// @description    Analyzes comments for movie in NicoNicoDouga 
    66// @license        The MIT License 
    7 // @version        0.1.2 
     7// @version        0.1.3 
    88// @released       2008-01-19 14:00:00 
    9 // @updated        2008-01-21 22:00:00 
     9// @updated        2008-01-23 03:00:00 
    1010// @compatible     Greasemonkey 
    1111// @include        http://www.nicovideo.jp/watch/* 
     
    2222        var waiting = new PE(function() { 
    2323                var flvplayer = unsafeWindow.document.getElementById('flvplayer'); 
    24                 var nico = flvplayer.GetVariable('o') || flvplayer.GetVariable('nico.o'); 
     24                var nico = flvplayer.GetVariable('o'); 
     25        if(nico == 'base') nico = flvplayer.GetVariable('nico.o'); 
    2526                if(nico && ready.test(nico)) { 
    2627                        var memo = nico.split('&'); 
     
    7778                this.comments = new Array(); 
    7879                this.__jQuery = unsafeWindow.jQuery; 
    79                 this.max = parseInt(size, 10); 
     80                //this.max = parseInt(size, 10); 
    8081        }, 
    8182        size: function() { return this.comments.length; }, 
     
    133134        get_waybackkey: function() { 
    134135                var self = this; 
    135                 GM_xmlhttpRequest({ 
     136        var endpoint = unsafeWindow.document.getElementById('flvplayer').GetVariable('B') || 
     137            unsafeWindow.document.getElementById('flvplayer').GetVariable('nico.B'); 
     138                GM_wrap(GM_xmlhttpRequest)({ 
    136139                        method: 'GET', 
    137140                        headers: { 
    138141                                'User-Agent': 'Mozilla/4.0 (compatible) Greasemonkey (NicoNicoDouga - Analytics)' 
    139142                        }, 
    140                         url: unsafeWindow.document.getElementById('flvplayer').GetVariable('B') 
    141                                 + 'getwaybackkey?thread=' + this.thread_id, 
     143                        url: endpoint + 'getwaybackkey?thread=' + this.thread_id, 
    142144                        onload: function(res) { 
    143145                                self.waybackkey = res.responseText.split('=')[1]; 
     
    157159                post_data += '/>'; 
    158160                var self = this; 
    159                 GM_xmlhttpRequest({ 
     161                GM_wrap(GM_xmlhttpRequest)({ 
    160162                        method: 'POST', 
    161163                        headers: { 
     
    177179                                } 
    178180                                comments.video_length = self.video_length; 
     181                if(!last) comments.max = thread.getAttribute('last_res'); 
    179182                                callback(comments, responseXML); 
    180183                        }, 
     
    190193        var thread_url = video_info.ms; 
    191194        var retriever = new Retriever(video_info); 
    192         var comments = new CommentSet($j('#flvplayer')[0].GetVariable('last_resno')); 
     195        var comments = new CommentSet(/*$j('#flvplayer')[0].GetVariable('last_resno')*/); 
    193196 
    194197        retriever.next(comments, plot); 
     
    530533        } 
    531534        #niconicodouga_analytics .gridLabel { font-size: 80%; } 
    532         .userscript_credit { 
     535        #niconicodouga_analytics p.userscript_credit { 
    533536        background-color: #333; 
    534537                border-top: 2px dotted #ccc; 
     
    537540                color: #ccc; 
    538541                text-align: center; 
    539         } 
    540         .userscript_credit a { 
     542        margin: 0; 
     543        } 
     544        #niconicodouga_analytics p.userscript_credit a { 
    541545                color: #fcc; 
    542546        } 
     
    717721]]></>); 
    718722 
     723// Greasemonkey 0.7.20080121.0 compatibility 
     724//   http://wiki.greasespot.net/0.7.20080121.0_compatibility 
     725function GM_wrap(f) { 
     726    return function() { 
     727        setTimeout.apply(window, [f, 0].concat([].slice.call(arguments))); 
     728    }; 
     729} 
     730 
    719731// Auto UserScript Updater 
    720732function UpdateChecker() {}; 
     
    722734    script_name: 'NicoNicoDouga Analytics', 
    723735    script_url: 'http://blog.fulltext-search.biz/files/niconicodougaanalytics.user.js', 
    724     current_version: '0.1.2', 
     736    current_version: '0.1.3', 
    725737    more_info_url: 'http://blog.fulltext-search.biz/pages/niconicodouga-analytics', 
    726738 
     
    762774        close_link.setAttribute('href', 'javascript:void(0);'); 
    763775        close_link.addEventListener('click', function() { 
    764             GM_setValue('last_check_day', self.beginning_of_day().toString()); 
     776            GM_wrap(GM_setValue)('last_check_day', self.beginning_of_day().toString()); 
    765777            var update_alert = document.getElementById('gm_update_alert'); 
    766778            update_alert.parentNode.removeChild(update_alert);