hwm_exit_from_war

HWM mod - Ssylka "vernut'sja v igru" na fleshke boja (by Demin)

当前为 2014-05-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name hwm_exit_from_war
  3. // @namespace Demin
  4. // @description HWM mod - Ssylka "vernut'sja v igru" na fleshke boja (by Demin)
  5. // @homepage http://userscripts.org/users/263230/scripts
  6. // @version 1.2
  7. // @include http://*heroeswm.ru/war*
  8. // @include http://178.248.235.15/war*
  9. // @include http://209.200.152.144/war*
  10. // @include http://*.lordswm.com/war*
  11. // @include http://*герои.рф/?15091
  12. // ==/UserScript==
  13.  
  14. // (c) 2013, demin ( http://www.heroeswm.ru/pl_info.php?id=15091 )
  15.  
  16. var version = '1.2';
  17.  
  18.  
  19. if (top != self) {
  20.  
  21. var div = document.createElement('div');
  22. div.setAttribute('style', 'position: absolute; background-color: #ffffff; border: 1px solid #999;');
  23. div.innerHTML = '<b><a href="home.php" style="text-decoration: none;">&nbsp;Home&nbsp;</a></b>';
  24. document.body.appendChild(div);
  25.  
  26. if ( document.querySelector("embed[src*='combat']") ) { update_div(div); } else { update_div2(div); }
  27.  
  28. }
  29.  
  30.  
  31. function update_div(div) {
  32. var flash_war = getOffset( document.querySelector("embed[src*='combat']") );
  33.  
  34. div.style.fontSize = Math.round( document.querySelector("object[id*='combat']").width / 60 ) + "px";
  35.  
  36. div.style.left = flash_war.left + 'px';
  37. div.style.top = flash_war.top + 'px';
  38.  
  39. setTimeout(function() { update_div(div); }, 999);
  40. }
  41.  
  42. function update_div2(div) {
  43. var cl_w = ClientWidth();
  44. var cl_h = ClientHeight();
  45.  
  46. if ( cl_w < 600 ) { cl_w = 600; }
  47. if ( cl_h < 366 ) { cl_h = 366; }
  48.  
  49. if ( cl_w > cl_h*600/366 ) {
  50. div.style.fontSize = Math.round( cl_h / 37 ) + "px";
  51.  
  52. div.style.left = Math.round( (cl_w-cl_h*600/366)/2 ) + 'px';
  53. div.style.top = '0px';
  54. } else {
  55. div.style.fontSize = Math.round( cl_w / 60 ) + "px";
  56.  
  57. div.style.left = '0px';
  58. div.style.top = Math.round( (cl_h-cl_w*366/600)/2 ) + 'px';
  59. }
  60.  
  61. setTimeout(function() { update_div2(div); }, 999);
  62. }
  63.  
  64. function ClientWidth() {
  65. return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
  66. }
  67.  
  68. function ClientHeight() {
  69. return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
  70. }
  71.  
  72. function getOffset(elem) {
  73. if (elem.getBoundingClientRect) {
  74. // pravilnyj
  75.  
  76. // (1)
  77. var box = elem.getBoundingClientRect()
  78.  
  79. // (2)
  80. var body = document.body
  81. var docElem = document.documentElement
  82.  
  83. // (3)
  84. var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop
  85. var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft
  86.  
  87. // (4)
  88. var clientTop = docElem.clientTop || body.clientTop || 0
  89. var clientLeft = docElem.clientLeft || body.clientLeft || 0
  90.  
  91. // (5)
  92. var top = box.top + scrollTop - clientTop
  93. var left = box.left + scrollLeft - clientLeft
  94.  
  95. return { top: Math.round(top), left: Math.round(left) }
  96.  
  97. } else {
  98. // hot kak to
  99.  
  100. var top=0, left=0
  101. while(elem) {
  102. top = top + parseInt(elem.offsetTop)
  103. left = left + parseInt(elem.offsetLeft)
  104. elem = elem.offsetParent
  105. }
  106.  
  107. return {top: top, left: left}
  108. }
  109. }