Changeset 5320
- Timestamp:
- 01/23/08 02:44:02 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/nicommentcloud.user.js
r3746 r5320 5 5 // @description Comment Cloud on Nico Nico Douga 6 6 // @license MIT License 7 // @version 0.1. 07 // @version 0.1.1 8 8 // @released 2007-12-28 23:30:00 9 // @updated 200 7-12-28 23:30:009 // @updated 2008-01-23 02:30:00 10 10 // @compatible Greasemonkey 11 11 // @include http://www.nicovideo.jp/watch/* … … 18 18 return; 19 19 } 20 var nico = unsafeWindow.$('flvplayer').GetVariable('o') ;20 var nico = unsafeWindow.$('flvplayer').GetVariable('o') || unsafeWindow.$('flvplayer').GetVariable('nico.o'); 21 21 if(nico && readyRegExp.test(nico)) { 22 22 waiting.stop(); 23 main( );23 main(nico); 24 24 } 25 25 }, 0.5); 26 26 27 function main( ) {27 function main(video_info) { 28 28 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); 32 30 var url = video_info.ms; 33 31 34 GM_ xmlhttpRequest({32 GM_wrap(GM_xmlhttpRequest)({ 35 33 method: 'POST', 36 34 headers: { … … 289 287 }; 290 288 289 // Greasemonkey 0.7.20080121.0 compatibility 290 // http://wiki.greasespot.net/0.7.20080121.0_compatibility 291 function GM_wrap(f) { 292 return function() { 293 setTimeout.apply(window, [f, 0].concat([].slice.call(arguments))); 294 }; 295 } 296 291 297 // Auto UserScript Updater 292 298 function UpdateChecker() {}; … … 294 300 script_name: 'Nicomment Cloud', 295 301 script_url: 'http://blog.fulltext-search.biz/files/nicommentcloud.user.js', 296 current_version: '0.1. 0',302 current_version: '0.1.1', 297 303 more_info_url: 'http://blog.fulltext-search.biz/pages/nicomment-cloud', 298 304 … … 334 340 close_link.setAttribute('href', 'javascript:void(0);'); 335 341 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()); 337 343 var update_alert = document.getElementById('gm_update_alert'); 338 344 update_alert.parentNode.removeChild(update_alert); … … 387 393 } 388 394 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 { 390 399 font-weight: bold; 391 400 } … … 395 404 // Check script update remote 396 405 check_update: function() { 397 if(!this.has_need_for_check ) return;406 if(!this.has_need_for_check()) return; 398 407 var user_script = this; 399 408 GM_xmlhttpRequest({ … … 406 415 user_script.render_update_info(); 407 416 } else { 408 GM_setValue('last_check_day', user_script. days_since_start());417 GM_setValue('last_check_day', user_script.beginning_of_day().toString()); 409 418 } 410 419 }, … … 416 425 // return [true] if necessary 417 426 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) { 421 430 return true; 422 431 } else { … … 434 443 }, 435 444 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() { 438 446 var now = new Date(); 439 return(n ow.getYear() * 365 + DAYS_IN_MONTH[now.getMonth()] + now.getDate());447 return(new Date(now.getFullYear(), now.getMonth(), now.getDate())); 440 448 } 441 449 }; 442 450 451 if(typeof GM_getValue('last_check_day') == 'number') 452 GM_setValue('last_check_day', "Thu Jan 01 1970 00:00:00 GMT+0900"); 443 453 var user_script = new UpdateChecker(); 444 454 user_script.check_update();
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)