Changeset 5320

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

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

Files:
1 modified

Legend:

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

    r3746 r5320  
    55// @description    Comment Cloud on Nico Nico Douga 
    66// @license        MIT License 
    7 // @version        0.1.0 
     7// @version        0.1.1 
    88// @released       2007-12-28 23:30:00 
    9 // @updated        2007-12-28 23:30:00 
     9// @updated        2008-01-23 02:30:00 
    1010// @compatible     Greasemonkey 
    1111// @include        http://www.nicovideo.jp/watch/* 
     
    1818        return; 
    1919    } 
    20         var nico = unsafeWindow.$('flvplayer').GetVariable('o'); 
     20        var nico = unsafeWindow.$('flvplayer').GetVariable('o') || unsafeWindow.$('flvplayer').GetVariable('nico.o'); 
    2121        if(nico && readyRegExp.test(nico)) { 
    2222                waiting.stop(); 
    23                 main(); 
     23                main(nico); 
    2424        } 
    2525}, 0.5); 
    2626 
    27 function main() { 
     27function main(video_info) { 
    2828    var MAX = 50, LIMIT = 100000 - 100; // Limit: 100KB - (query parameter).length 
    29         var flvplayer = unsafeWindow.$('flvplayer'); 
    30         flvplayer.get = function(target) { return this.GetVariable(target); }; 
    31         var video_info = flvplayer.get('o').split('&').inject({}, parseQueryString); 
     29        var video_info = video_info.split('&').inject({}, parseQueryString); 
    3230        var url = video_info.ms; 
    3331 
    34         GM_xmlhttpRequest({ 
     32        GM_wrap(GM_xmlhttpRequest)({ 
    3533                method: 'POST', 
    3634                headers: { 
     
    289287}; 
    290288 
     289// Greasemonkey 0.7.20080121.0 compatibility 
     290//   http://wiki.greasespot.net/0.7.20080121.0_compatibility 
     291function GM_wrap(f) { 
     292    return function() { 
     293        setTimeout.apply(window, [f, 0].concat([].slice.call(arguments))); 
     294    }; 
     295} 
     296 
    291297// Auto UserScript Updater 
    292298function UpdateChecker() {}; 
     
    294300    script_name: 'Nicomment Cloud', 
    295301    script_url: 'http://blog.fulltext-search.biz/files/nicommentcloud.user.js', 
    296     current_version: '0.1.0', 
     302    current_version: '0.1.1', 
    297303    more_info_url: 'http://blog.fulltext-search.biz/pages/nicomment-cloud', 
    298304 
     
    334340        close_link.setAttribute('href', 'javascript:void(0);'); 
    335341        close_link.addEventListener('click', function() { 
    336             GM_setValue('last_check_day', self.days_since_start()); 
     342            GM_wrap(GM_setValue)('last_check_day', self.beginning_of_day().toString()); 
    337343            var update_alert = document.getElementById('gm_update_alert'); 
    338344            update_alert.parentNode.removeChild(update_alert); 
     
    387393            } 
    388394 
    389             #gm_update_alert p + a:link { 
     395            #gm_update_alert p + a:link, 
     396            #gm_update_alert p + a:visited, 
     397            #gm_update_alert p + a:active, 
     398            #gm_update_alert p + a:hover { 
    390399                font-weight: bold; 
    391400            } 
     
    395404    // Check script update remote 
    396405    check_update: function() { 
    397         if(!this.has_need_for_check) return; 
     406        if(!this.has_need_for_check()) return; 
    398407        var user_script = this; 
    399408        GM_xmlhttpRequest({ 
     
    406415                    user_script.render_update_info(); 
    407416                } else { 
    408                     GM_setValue('last_check_day', user_script.days_since_start()); 
     417                    GM_setValue('last_check_day', user_script.beginning_of_day().toString()); 
    409418                } 
    410419            }, 
     
    416425    // return [true] if necessary 
    417426    has_need_for_check: function() { 
    418         var last_check_day = GM_getValue('last_check_day'); 
    419         var current_day = this.days_since_start(); 
    420         if(typeof last_check_day == 'undefined' || current_day > last_check_day) { 
     427        var last_check_day = new Date(GM_getValue('last_check_day', "Thu Jan 01 1970 00:00:00 GMT+0900")); 
     428        var current_day = this.beginning_of_day(); 
     429        if(current_day > last_check_day) { 
    421430            return true; 
    422431        } else { 
     
    434443    }, 
    435444 
    436     days_since_start: function() { 
    437         var DAYS_IN_MONTH = [31,59,90,120,151,181,212,243,273,304,334,365]; 
     445    beginning_of_day: function() { 
    438446        var now = new Date(); 
    439         return(now.getYear() * 365 + DAYS_IN_MONTH[now.getMonth()] + now.getDate()); 
     447        return(new Date(now.getFullYear(), now.getMonth(), now.getDate())); 
    440448    } 
    441449}; 
    442450 
     451if(typeof GM_getValue('last_check_day') == 'number') 
     452    GM_setValue('last_check_day', "Thu Jan 01 1970 00:00:00 GMT+0900"); 
    443453var user_script = new UpdateChecker(); 
    444454user_script.check_update();