Greasy Fork 支持简体中文。

hwm_cgame_time

HWM mod - Prodolzhitel'nost' kartochnogo boja (by Demin)

目前為 2014-08-16 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name hwm_cgame_time
  3. // @namespace Demin
  4. // @description HWM mod - Prodolzhitel'nost' kartochnogo boja (by Demin)
  5. // @homepage http://userscripts.org/users/263230/scripts
  6. // @version 3.3
  7. // @include http://*heroeswm.ru/cgame*
  8. // @include http://178.248.235.15/cgame*
  9. // @include http://209.200.152.144/cgame*
  10. // @include http://*lordswm.com/cgame*
  11. // ==/UserScript==
  12.  
  13. // (c) 2011-2013, demin ( http://www.heroeswm.ru/pl_info.php?id=15091 )
  14.  
  15. var version = '3.3';
  16.  
  17.  
  18. var time_begin = new Date().getTime();
  19. if ( !window.sidebar ) {
  20. setTimeout(function() { document.querySelector("object[id*='arcomag']").innerHTML += '<param name="wmode" value="opaque" />'; }, 200);
  21. }
  22.  
  23. var div = document.createElement('div');
  24. div.setAttribute('style', 'position: absolute; background-color: #77b5fa;');
  25. document.body.appendChild(div);
  26.  
  27. if ( document.querySelector("embed[src*='arcomag']") ) { setTimeout(function() { update_div(div, time_begin); }, 999); } else { setTimeout(function() { update_div2(div, time_begin); }, 999); }
  28.  
  29.  
  30. function update_div(div, time_begin) {
  31. var ct = Math.floor( ( new Date().getTime() - time_begin ) / 1000 );
  32. var dm = Math.floor( ct / 60 ) % 60;
  33. var ds = ct % 60;
  34. div.innerHTML = '<b>&nbsp;' + dm + ':' + ( (ds < 10) ? '0' : '' ) + ds + '&nbsp;</b>';
  35.  
  36. var flash_war = document.querySelector("embed[src*='arcomag']").getBoundingClientRect();
  37. var flash_war_width = document.querySelector("object[id*='arcomag']").width;
  38. var flash_war_height = document.querySelector("object[id*='arcomag']").height;
  39.  
  40. div.style.fontSize = Math.round( flash_war_width / 70 ) + 'px';
  41.  
  42. div.style.left = flash_war.left + flash_war_width * 0.21 + 'px';
  43. div.style.top = flash_war.top + flash_war_height * 0.05 + 'px';
  44.  
  45. setTimeout(function() { update_div(div, time_begin); }, 999);
  46. }
  47.  
  48. function update_div2(div, time_begin) {
  49. var ct = Math.floor( ( new Date().getTime() - time_begin ) / 1000 );
  50. var dm = Math.floor( ct / 60 ) % 60;
  51. var ds = ct % 60;
  52. div.innerHTML = '<b>&nbsp;' + dm + ':' + ( (ds < 10) ? '0' : '' ) + ds + '&nbsp;</b>';
  53.  
  54. var cl_w = ClientWidth();
  55. var cl_h = ClientHeight();
  56.  
  57. if ( cl_w < 600 ) { cl_w = 600; }
  58. if ( cl_h < 366 ) { cl_h = 366; }
  59.  
  60. if ( cl_w > ( cl_h * 600 / 366 ) ) {
  61. div.style.fontSize = Math.round( cl_h / 43 ) + 'px';
  62.  
  63. div.style.left = Math.round( ( cl_w / 2 - cl_h * 600 / 366 * 0.29 ) ) + 'px';
  64. div.style.top = cl_h * 0.05 + 'px';
  65. } else {
  66. div.style.fontSize = Math.round( cl_w / 70 ) + 'px';
  67.  
  68. div.style.left = cl_w * 0.21 + 'px';
  69. div.style.top = Math.round( ( cl_h / 2 - cl_w * 366 / 600 * 0.45 ) ) + 'px';
  70. }
  71.  
  72. setTimeout(function() { update_div2(div, time_begin); }, 999);
  73. }
  74.  
  75. function ClientHeight() {
  76. return document.compatMode=='CSS1Compat' && document.documentElement?document.documentElement.clientHeight:document.body.clientHeight;
  77. }
  78.  
  79. function ClientWidth() {
  80. return document.compatMode=='CSS1Compat' && document.documentElement?document.documentElement.clientWidth:document.body.clientWidth;
  81. }