hwm_tavern_delete

HWM mod - Tavern delete by Demin

  1. // ==UserScript==
  2. // @name hwm_tavern_delete
  3. // @namespace Demin
  4. // @description HWM mod - Tavern delete by Demin
  5. // @homepage http://userscripts.org/scripts/show/142614
  6. // @version 1.00
  7. // @include http://*heroeswm.*/*
  8. // @include http://178.248.235.15/*
  9. // @include http://*lordswm.*/*
  10. // @include http://*герои.рф/?15091
  11. // ==/UserScript==
  12.  
  13. // (c) 2012, demin (http://www.heroeswm.ru/pl_info.php?id=15091)
  14.  
  15. var version = '1.00';
  16.  
  17. var script_num = 142614;
  18. var script_name = 'HWM mod - Tavern delete by Demin';
  19. var string_upd = /142614=(\d+\.\d+)/;
  20.  
  21. var url_cur = location.href;
  22. var url = 'http://'+location.hostname+'/';
  23.  
  24. try {
  25.  
  26. if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
  27. this.GM_getValue=function (key,def) {
  28. return localStorage[key] || def;
  29. };
  30. this.GM_setValue=function (key,value) {
  31. return localStorage[key]=value;
  32. };
  33. this.GM_deleteValue=function (key) {
  34. return delete localStorage[key];
  35. };
  36. }
  37.  
  38. if ( (tag('body'))[0] ) {
  39.  
  40. var dfv = '<b>\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436</b>';
  41. var regexp_r = /\u0422\u0430\u0432\u0435\u0440\u043d\u0430\./;
  42. var regexp_r2 = /\u0422\u0435\u043a\u0443\u0449\u0438\u0435 \u0438\u0433\u0440\u044b/;
  43. var regexp_r3 = /\d\d-\d\d-\d\d /;
  44. var regexp_r4 = /cards\.gif/;
  45. if (url.match('lordswm')) {
  46. dfv = '<b>Character</b>';
  47. regexp_r = /Tavern\./;
  48. regexp_r2 = /Current games/;
  49. }
  50.  
  51. // chat
  52. if ( location.pathname=='/chat_line.php' ) {
  53. var all_a = tag('option');
  54. var a_len = all_a.length;
  55. for (var i=a_len; i--;) {
  56. var a_i = all_a[i];
  57. if ( a_i.innerHTML.match(/\u0422\u0430\u0432\u0435\u0440\u043d\u0430/) || a_i.innerHTML.match(/Tavern/) ) {
  58. a_i.parentNode.removeChild(a_i);
  59. }
  60. }
  61. }
  62.  
  63. // menu
  64. var all_a = tag('li');
  65. var a_len = all_a.length;
  66. for (var i=a_len; i--;) {
  67. var a_i = all_a[i];
  68. if ( a_i.innerHTML.match(/frames\.php\?room=5/) && !a_i.innerHTML.match(/<b>/) ) {
  69. a_i.parentNode.removeChild(a_i);
  70. }
  71. }
  72. var all_a = tag('a');
  73. var a_len = all_a.length;
  74. for (var i=a_len; i--;) {
  75. var a_i = all_a[i];
  76. if ( a_i.href.match(/tavern\.php/) && a_i.innerHTML.match(/<b>.+<\/b>/) ) {
  77. a_i.href = 'home.php';
  78. a_i.innerHTML = dfv;
  79. }
  80. }
  81. var all_a = tag('td');
  82. var a_len = all_a.length;
  83. for (var i=a_len; i--;) {
  84. if ( all_a[i].innerHTML.indexOf("<td")!=-1 ) {continue;}
  85. if ( regexp_r4.exec(all_a[i].innerHTML) ) {
  86. all_a[i].style.display = 'none';
  87. break;
  88. }
  89. }
  90.  
  91. // tavern
  92. if ( location.pathname=='/tavern.php' ) {
  93. var all_a = tag('table');
  94. var a_len = all_a.length;
  95. for (var i=a_len; i--;) {
  96. if ( regexp_r.exec(all_a[i].innerHTML) ) {
  97. if ( !regexp_r.exec(all_a[i+1].innerHTML) ) {
  98. all_a[i-1].style.display = 'none';
  99. break;
  100. }
  101. }
  102. }
  103. }
  104. if ( location.pathname=='/tavern_games.php' ) {
  105. var all_a = tag('table');
  106. var a_len = all_a.length;
  107. for (var i=a_len; i--;) {
  108. if ( regexp_r2.exec(all_a[i].innerHTML) ) {
  109. if ( !regexp_r2.exec(all_a[i+1].innerHTML) ) {
  110. all_a[i-1].style.display = 'none';
  111. break;
  112. }
  113. }
  114. }
  115. }
  116. if ( location.pathname=='/cgame.php' ) {
  117. var all_a = tag('html');
  118. var a_len = all_a.length;
  119. for (var i=a_len; i--;) {
  120. all_a[i].style.display = 'none';
  121. break;
  122. }
  123. }
  124. if ( location.pathname=='/arc_tour_hist.php' ) {
  125. var all_a = tag('table');
  126. var a_len = all_a.length;
  127. for (var i=a_len; i--;) {
  128. if ( regexp_r3.exec(all_a[i].innerHTML) ) {
  129. if ( !regexp_r3.exec(all_a[i+1].innerHTML) ) {
  130. all_a[i-1].style.display = 'none';
  131. break;
  132. }
  133. }
  134. }
  135. }
  136.  
  137. }
  138.  
  139. } finally {
  140. if ( location.pathname=='/tavern.php' || location.pathname=='/tavern_games.php' || location.pathname=='/cgame.php' || location.pathname=='/arc_tour_hist.php' || ( location.pathname=='/frames.php' && location.search && location.search.match(/room=5/) ) )
  141. {
  142. setTimeout(function() { window.location=url+'home.php'; }, 300);
  143. setTimeout(function() { window.location=url+'home.php'; }, 5000);
  144. }
  145.  
  146. update_n()
  147. }
  148.  
  149. function $( id ) { return document.getElementById( id ); }
  150.  
  151. function tag( id ) { return document.getElementsByTagName( id ); }
  152.  
  153. function addEvent(elem, evType, fn) {
  154. if (elem.addEventListener) {
  155. elem.addEventListener(evType, fn, false);
  156. }
  157. else if (elem.attachEvent) {
  158. elem.attachEvent("on" + evType, fn)
  159. }
  160. else {
  161. elem["on" + evType] = fn
  162. }
  163. }
  164.  
  165. function createXMLHttpReq(rndm)
  166. {
  167. var objXMLHttpReq;
  168. if (window.XMLHttpRequest)
  169. {
  170. // Real browsers ;)
  171. //
  172. objXMLHttpReq = new XMLHttpRequest();
  173. }
  174. else if (window.ActiveXObject)
  175. {
  176. // IE
  177. //
  178. objXMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
  179. }
  180. return objXMLHttpReq;
  181. }
  182.  
  183. function update_n() {
  184. if ( (parseInt(GM_getValue('last_update', '0')) + 86400000 <= (new Date().getTime())) || (parseInt(GM_getValue('last_update', '0')) > (new Date().getTime())) ) {
  185. var objXMLHttpReqUpd = createXMLHttpReq(Math.random()* 1000000);
  186. objXMLHttpReqUpd.open('GET', url + 'photo_pl_photos.php?aid=1777' + '&rand=' + (Math.random()* 1000000), true);
  187. objXMLHttpReqUpd.onreadystatechange = function() { update(objXMLHttpReqUpd); }
  188. objXMLHttpReqUpd.send(null);
  189. }
  190. }
  191. function update(obj) {
  192. if (obj.readyState == 4 && obj.status == 200) {
  193. var update_text1 = '\n\n\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0435 Greasemonkey \u0441\u043A\u0440\u0438\u043F\u0442\u0430 "';
  194. var update_text2 = '".\n\u0425\u043E\u0442\u0438\u0442\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u043D\u0443\u044E \u0432\u0435\u0440\u0441\u0438\u044E?';
  195. var remote_version, rt;rt=obj.responseText;GM_setValue('last_update', ''+new Date().getTime());remote_version=string_upd.exec(rt)[1];if(version!=-1){if (remote_version > version) setTimeout(function() { if(confirm('There is an update available for the Greasemonkey script "'+script_name+'".\nWould you like to go to the install page now?'+update_text1+script_name+update_text2)){window.open('http://userscripts.org/scripts/show/'+script_num, '_blank')} }, 100) }}
  196. }