hwm_time_restore

Таймеры гильдии рабочих, воров, наёмников, рейнджеров, охотников, кузнецов, восстановления здоровья и маны (by Demin & перф)

目前为 2018-11-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name hwm_time_restore
  3. // @namespace Demin_92571
  4. // @author Demin
  5. // @description Таймеры гильдии рабочих, воров, наёмников, рейнджеров, охотников, кузнецов, восстановления здоровья и маны (by Demin & перф)
  6. // @homepage https://greasyfork.org/users/1602-demin
  7. // @icon http://i.imgur.com/LZJFLgt.png
  8. // @version 6.0.3
  9. // @encoding utf-8
  10. // @include https://www.heroeswm.ru/*
  11. // @include https://qrator.heroeswm.ru/*
  12. // @include https://178.248.235.15/*
  13. // @include https://www.lordswm.com/*
  14. // @exclude */rightcol.php*
  15. // @exclude */ch_box.php*
  16. // @exclude */chat*
  17. // @exclude */ticker.html*
  18. // @exclude */frames*
  19. // @exclude */brd.php*
  20. // @grant GM_deleteValue
  21. // @grant GM_getValue
  22. // @grant GM_listValues
  23. // @grant GM_setValue
  24. // @grant GM_addStyle
  25. // @grant GM_log
  26. // @grant GM_openInTab
  27. // ==/UserScript==
  28.  
  29. // (c) 2010-2015, demin ( https://www.heroeswm.ru/pl_info.php?id=15091 )
  30. // (c) 2008-2009, xo4yxa
  31. // (c) 2017, перф. 10.10.2017 v.5.8: *вместо nick привзяка к id_payler из рекордов охоты; изменение алгоритма получения уровня здоровья.
  32. // (c) 2018, CheckT v.6.0.3: Исправления и рефакторинг
  33.  
  34. try{
  35. (function() {
  36.  
  37. initGm();
  38.  
  39. var url_cur = location.href;
  40. var url = 'https://'+location.hostname+'/';
  41. var gm_prefix = "htr_";
  42.  
  43. // в бою
  44. if ( location.pathname=='/war.php' && /warlog\|0/.exec(document.querySelector("html").innerHTML) ) {
  45. gm_set_bool( "war_unload_"+location.hostname );
  46. }
  47.  
  48. var pl_id = getPlayerId();
  49.  
  50. var img_link = document.querySelector("img[src*='i/top'][src*='/line/t_end']");
  51.  
  52. var b = document.querySelector("body");
  53. var x1 = document.querySelector("img[src*='i/top'][src*='/dragon__left']");
  54. var x2 = document.querySelector("img[src*='i/top'][src*='/dragon__right']");
  55.  
  56. if ( !b || !img_link || !x1 || !pl_id)
  57. return;
  58.  
  59. if(convertOptions())
  60. return;
  61.  
  62. var army_percent = 0;
  63. var vh = document.getElementById('heart')
  64. if (vh && vh.parentNode.innerHTML.match(/var heart=(\d+);/))
  65. army_percent = RegExp.$1
  66.  
  67. var _i = /(\S*\/line\/)/.exec(img_link.src)[1];
  68. var _i_ = '';
  69.  
  70. // если новый год
  71. if ( document.querySelector("img[src*='i/top_ny']") )
  72. _i_ = '_';
  73.  
  74. var time_cur = new Date().getTime();
  75. var time = { h: 0, w: 0, gn: 0, gv: 0, go: 0, sm: 0 }
  76.  
  77. var options = loadOptions();
  78. var audio = initAudio();
  79.  
  80. var texts = setTexts();
  81.  
  82. alertOnLicMo();
  83. createTopRow();
  84. var time_server = loadServerTime();
  85. loadWorkEndTime();
  86. checkAbu();
  87. checkLicMoO();
  88. checkWar();
  89. checkJustWork();
  90. checkWork();
  91. checkMercenary();
  92. checkRangerGuild();
  93. checkModWorkebench();
  94. checkMap();
  95. addEvents();
  96. showTimers();
  97. gm_set(pl_id+'_options', JSON.stringify(options));
  98. return;
  99.  
  100. //only functions below
  101.  
  102. function loadOptions(){
  103. var options = gm_get(pl_id+'_options');
  104. if ( !options )
  105. options = '{"time_health_alert":"no", "time_work_alert":"yes", "time_work_end_yes":"yes", "time_work_end":"1300000000000", "time_work_trudogolik":"0", "time_sm_alert":"yes", "time_sm_end_yes":"yes", "time_sm_end":"1300000000000", "time_gn_alert":"yes", "time_gn_end_yes":"yes", "time_gn_end":"1300000000000", "time_go_alert":"yes", "time_go_end_yes":"yes", "time_go_end":"1300000000000", "map_hunter":"false", "time_gv_alert":"yes", "time_gv_end_yes":"yes", "time_gv_end":"1300000000000", "map_thief_ambush":"false", "time_percent_faster":"1", "time_percent_prem":"1", "time_percent_prem_exp":"1300000000000", "time_percent_prem_title":"", "time_percent_lic_mo":"1", "time_percent_lic_mo_exp":"1300000000000", "time_percent_lic_mo_title":"", "gv_or_gre":"0", "gre_check":"0", "time_work_trudogolik_show":"1", "time_work_trudogolik_off":"0", "gr_show_check":"1", "gk_show_check":"1", "gn_show_check":"1", "go_show_check":"1", "gv_show_check":"1", "go_timer_hide":"1", "object_id":""}';
  106. return JSON.parse( options );
  107. }
  108. function updateOption(key, val){
  109. options = getOptions();
  110. options[key] = val;
  111. setOptions(options);
  112. }
  113. function getOptions(){
  114. return JSON.parse(gm_get(pl_id+'_options', '{}'));
  115. }
  116. function setOptions(options){
  117. gm_set(pl_id+'_options', JSON.stringify(options));
  118. }
  119.  
  120. function initAudio(){
  121. // Звуковой сигнал
  122. var audio = new Audio();
  123. audio.preload = 'auto';
  124. if(options["time_audio_file"]){
  125. audio.src = options["time_audio_file"];
  126. } else {
  127. audio.src = 'data:audio/mp4;base64,' +
  128. '/+OAxAAAAAAAAAAAAEluZm8AAAAPAAAABQAACcoAMzMzMzMzMzMzMzMzMzMzMzMzM2ZmZmZmZmZmZmZmZmZmZmZmZmZmmZmZmZmZmZmZmZmZmZmZmZmZmZnMzMzMzMzMzMzMzMzMzMzMzMzMzP//////////////////////////AAAAOUxBTUUzLjk4cgE3AAAAAAAAAAAUQCQCTiIAAEAAAAnKGRQoyQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+OAxABX1F4koVjAAQjCEwjMYQMNFN52kFuDMg7zN6S6b5yx01M0x11uJOV6eYZQoAsSQOw1xyGGKAISEUHFBIzpQ4IL0Piieg+pvC30VO49A5D8R9h6gag6YDTJKsOmOseB4gzhU6Y6g7E37tSik5MMoRMLYFtEUGmQaoGWkLwLonYbcty2tqnQCJEMsnK9Pbr07+P5GKTGvK4bf9yH8lmFSURixK2cM4dyWXYbcty5fz5h2GGKAKCOo4ZdxBxTRrjkNYdyUqZlkCzCKDEIpjTxt/3IchyIcxlb/v/D8s5Xp+yh/IcvUljCpKHYdyWXXYYYoAhIQCIOKaQlc5aQuIuicz1SVXbVIoAqRYjEIcvSt/3IfycrxuNy+/Uht/3/l9yGGsM4a4xN36ZlCJhchAAzRgYAAYAFmEHFiPxVhty2uO5OV43G7esK8bdt34vchhrC7FB2XypciEhAImA8jSy7iABdEUrxuNy/sdUgMCEYDAYDIYDEYDEYCeapz8c1sF1vw7MA2FaUsp8YwZDBEYNhWZMjfLOfb9r5p0lxsxHh/+OCxDRkHGbSX5nqA8jG0fWPNSWWZzFJWn3iM+keNcjuMPAiMRxVMchckCm7dWzuJA7X25tHSGDhiM0jUGg8MwA6MVRlMeRFc4LgGgPTMdOTpuI4vqhQgA4YtFoZTF4aHDYY3j+FQNMJQfAAi4ax7z82SvnelEritIYJgGucGiKYohiYMAUZKC4YkCcTDAZFD134cs58m6fmMst8qcprjzGKwLgIXzAkATBsETDcUzIgPDDwQjDgFTBwCQoEZgqBJhEF2OfcOc/Cn7hqWxqSTk3STW5fP0XgIdDBABjGAMDCQJAKCYQHaYBheG5YCoqAOYMA6BBHIQqMFgDblLOU/cKev2nzz53fK+7dLQasZSvPlXDehUIQ4CCIADBYCGJGCgFGBAZEIEgEFjB0AAQIqQxg4Dq9QgHUrTBsATAsGRCBBhuD///8z1+ff/P////+7/Llzes8/u/++cw59bO7zD///33////V4SolSuRCmPL6nAqR9ZQ0l+oyuAOCyR+7FK1oVDzAwRqbMUv6FhjNAQEMzLsmIgS1UOBgAImIjQoipf/jgsQ4ZLx2nAGY2ADAELIgUAh5h5eawLGRKBiAwYwIDS0ZmSGrrBAOmEGpgouigCBMxr2N3HiEvAQ2aIDGiCZphKHYxkpACC0WAgEWEJSRLJMWI9mGDJdQCFQcamMhKN7LzABcSEjHA8AA5elmCe6Wyi8XQAKiAgOjA3eGCAEC4GQCqXiwTLlTL5YaBQRe6EhFFL9fUOA0AL3Q64KYyQbgt8mkv1/V9P4JChgQoIASD1WhYEVpesZBH3VMAQBB5E1E5H4mAwAALneJRhsr1OGyC1DFaKvMma+jkOosKrLL2iNOadDTcpLBz1Mob+FzywCx3ThmMsqTXZiplIWdwPIXRj7WqRrDayxfVC8V+dl1aRR2NtKd6IwPBzgOHArgzcOydwWEtee5yqC3EKOBYBlNSIajDvVs696AXWjEzYj0zWiESlUWuWsb+M/aiFL3KW5SCe1fmpBWfr/+kk8SlmOX/9LVpKtJMzwBIiRGAngdQbAVvPs+70vm3FR5QGDWsugz5YIx02MFFn6TrWuxJy7xiJkYuqGZsQKPgUHGFgQUFQr/44LEOmbMdnABmdgAhKn3zEAY9pkI2cEtkxQaUamfHRgpKYkJoiCQyjYDgEw0JAwcu8oDzYms8RzMdCgUxpsEIUDSIEgZkBmBQsQASPSb7jusKggBA0bDEgFDEtgRBDSAMhKao2qGq3ofo0Q+pg+rdk92msTdeNCMGMCHzCgMUDQsEjAAFi9CS2NSLCkt1uQ+mMtOEyt6EAa4FRqWr4f2BncV48oMCRoXTaC4EoEAjss8vQVBCAAXmuFmzrq+bm26eLBIQ6LLnpruZTO0uh2WRZOBAEFID2syWVM6CoEIwRJp2m7JdqmZul6sLATxwJC3QdtNVrssgZuLSoKguZbDIG4uk+9O3sATbiWKSBtOUpasEyNjmC5Y7EZUwaJtNhpXUudGaf9nNO1xsbcFG2MwFLnphyLy+JPO0xpD708akEpls9Ny2Q0sbi71zrcYzFYlGnqxr7d+UvHK4nDjnf/wbDz0WJFR//tfoLTcY9mqAQMgAqUQjTA76PNjioDGCBQNciLWVhUVUiVilrWC2KV2VhS/qgKJpbEABLIqbRNHks6W/+OCxDNgzGY2JdjIAGUFX4R6LZMFZkWeMMQxQEuhEGaDZvQmaMmtfyoVKQASaC5sNmWQXSdaOsNSFQkoqoml/i0xbZMKFOCoCiqiqu53n+f6HpdnKX1ZUmMisptAzopelsS0qRSxlhkTi7xeJMJl0ndJL4u8g8sZymHJDISmWyhcyQyAZB5IpUzEp19lhlAlTLuZ0153qjKlAkVkVkVi7xaYtMumDFAkJSAZIpQYvEhKL+lpS2qKLTXiQTAEIwxEHXVw7KXZWFTFRVXc/Wcpf1/X9f2WzLWWIuLOPssMoEkMkKgFQCpgurAScxd4uUsWQ/Vdlhq7VSrti0y/stwymXBZzFoi1lhrEWuw7hammtM6fqbXKXVAAJhBoPOtnS8rQ1DUPWa0af52nKcpynKayu1drOX5vSp/n+hmMwy/rWVMS4JgCmIKuqVspXau1iLOXJcmNS7tWlpcJVGqXlVMQU1FMy45OC40VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==';
  129.  
  130. }
  131. return audio;
  132. }
  133.  
  134. function setTexts(){
  135. var obj;
  136. if (url.match('lordswm')) {
  137. obj = {
  138. health_alert_ty : 'Army restore alarm on',
  139. health_alert_tn : 'Alarm once at army restore',
  140. work_alert_ty : 'Workshift alarm on',
  141. work_alert_tn : 'Alarm off',
  142. sm_alert_ty : 'Blacksmith alarm on',
  143. gn_alert_ty : 'Mercenaries Guild alarm on',
  144. regexp_timegn0 : /Come back in (\d+) minutes\./,
  145. regexp_timegn1 : /\. Time left: (\d+) minutes\./,
  146. regexp_timegn2 : /ou have (\d+) minutes left/,
  147. regexp_timegn3 : /\. Time left: (\d+) minutes\./,
  148. regexp_timegn4 : /still have (\d+) minutes/,
  149. regexp_timegn5 : /you still have \d+ attempts and (\d+) minutes/,
  150. regexp_gn_rep : /Reputation: <b>([\d\.]+)/,
  151. go_alert_ty : 'Hunters Guild alarm on',
  152. regexp_go_timer : 'Next hunt available in',
  153. gv_alert_ty : 'Thieves Guild alarm on',
  154. gre_alert_ty : 'Rangers Guild alarm on',
  155. regexp_timegre : /Come in (\d+) min/,
  156. time_home : /You may enroll again in (\d+) min/,
  157. time_home2 : / since (\d+):(\d+)<\/td>/,
  158. alert_health : 'Troops ready: 100%',
  159. alert_work : 'LG: You may enroll again',
  160. alert_sm : 'BS: Blacksmith works are finished',
  161. alert_gn : 'MG: Mercenaries Guild has a quest for you',
  162. alert_go : 'HG: You notice traces ...',
  163. alert_gv : 'TG: You may set an ambush',
  164. alert_gre : 'RG: Rangers Guild has a quest for you',
  165. gr_t : 'LG',
  166. gr_title : '',
  167. gk_t : 'BS',
  168. gk_title : 'To Blacksmith',
  169. gn_t : 'MG',
  170. gn_title : 'To Mercenaries\' Guild',
  171. go_t : 'HG',
  172. go_title : 'To Hunters\' Guild',
  173. gv_t : 'TG',
  174. gv_title : 'To Thieves\' Guild',
  175. gre_t : 'RG',
  176. gre_title : 'To Rangers Guild post',
  177. mana_title : 'Settings',
  178. work_obj_do : 'You have successfully enrolled',
  179. work_unemployed : 'You are currently unemployed',
  180. regexp_map_go : 'During the journey you have access to the',
  181. go_title_lic : 'The license expires ',
  182. alert_go_lic_exp : 'HG: Hunter license has expired',
  183. alert_prem_exp : 'Abu-Bakir\'s Charm has expired',
  184. st_start : 'All settings adjustments will apply after page is reloaded',
  185. st_null_timers : 'Reset all timers',
  186. st_gv_n_time : 'Set TG/RG timer for once to',
  187. st_percent_faster : 'Quests HG, MG, TG, RG more often',
  188. st_gre_check : 'Immediately initiate Rangers\' guild battle on arrival',
  189. st_show_timers : 'Show timers:',
  190. st_predupr_pa : '<b>Abu-Bakir\'s Charm</b> is detected automatically',
  191. st_work_trudogolik_show : 'Notify about workaholic penalty only 2 workshifts away',
  192. st_work_trudogolik_off : 'Turn off all notifications on workaholic penalty',
  193. st_predupr_go_lic : '<b>Hunter license</b> is detected automatically in Hunters\' Guild',
  194. st_go_timer_hide : 'Hide',
  195. workaholic_penalty : 'Workaholic penalty',
  196. workaholic_penalty_regexp : 'workaholic penalty',
  197. regexp_sm : /Completion time: (\d+)-(\d+) (\d+):(\d+)/,
  198. workaholic_text1 : ' approximately through ',
  199. workaholic_text2 : ' enrollments.',
  200. workaholic_text3 : '',
  201. workaholic_text1_replace : ' <font color:"red">enabled</font> approximately ',
  202. uze_ustroen : 'You are already employed\.',
  203. uze_ustroen2 : 'Less than one hour passed since last enrollment\. Please wait\.',
  204. uze_ustroen3 : 'No vacancies\.'
  205. };
  206. } else {
  207. obj = {
  208. health_alert_ty : 'Будет предупреждение о восстановлении армии',
  209. health_alert_tn : 'Установить единоразово предупреждение о восстановлении армии',
  210. work_alert_ty : 'Будет предупреждение о конце рабочего часа',
  211. work_alert_tn : 'Не будет предупреждения',
  212. sm_alert_ty : 'Будет предупреждение о завершении работ в Кузнице',
  213. gn_alert_ty : 'Будет предупреждение Гильдии Наемников',
  214. regexp_timegn0 : /Приходи через (\d+) мин/,
  215. regexp_timegn1 : /Осталось времени: (\d+) минут/,
  216. regexp_timegn2 : /тебя осталось (\d+) минут/,
  217. regexp_timegn3 : /у тебя еще есть (\d+) минут/,
  218. regexp_timegn4 : /\. Осталось (\d+) минут\./,
  219. regexp_timegn5 : /осталось \d+ попыток и (\d+) минут/,
  220. regexp_gn_rep : /Репутация: <b>([\d\.]+)/,
  221. go_alert_ty : 'Будет предупреждение Гильдии Охотников',
  222. regexp_go_timer : 'Следующая охота будет доступна через',
  223. gv_alert_ty : 'Будет предупреждение Гильдии Воров',
  224. gre_alert_ty : 'Будет предупреждение Гильдии Рейнджеров',
  225. regexp_timegre : /приходи через (\d+) мин/,
  226. time_home : /Вы можете устроиться на работу через (\d+)/,
  227. time_home2 : / с (\d+):(\d+)<\/td>/,
  228. alert_health : 'Готовность армии: 100%',
  229. alert_work : 'ГР: Пора на работу',
  230. alert_sm : 'ГК: Работа в Кузнице завершена',
  231. alert_gn : 'ГН: Для Вас есть задание в Гильдии Наемников',
  232. alert_go : 'ГО: Вы увидели следы ...',
  233. alert_gv : 'ГВ: Вы можете устроить засаду',
  234. alert_gre : 'ГРж: Есть задание в Гильдии Рейнджеров',
  235. gr_t : 'ГР',
  236. gr_title : '',
  237. gk_t : 'ГК',
  238. gk_title : 'В Кузницу',
  239. gn_t : 'ГН',
  240. gn_title : 'В здание Гильдии Наемников',
  241. go_t : 'ГО',
  242. go_title : 'В здание Гильдии Охотников',
  243. gv_t : '\u0413\u0412',
  244. gv_title : 'В здание Гильдии Воров',
  245. gre_t : 'ГРж',
  246. gre_title : 'В здание Гильдии Рейнджеров',
  247. mana_title : 'Настройки',
  248. work_obj_do : 'Вы устроены на работу',
  249. work_unemployed : 'Вы нигде не работаете',
  250. regexp_map_go : 'Во время пути Вам доступны',
  251. go_title_lic : 'Лицензия истекает ',
  252. alert_go_lic_exp : 'ГО: Лицензия охотника истекла',
  253. alert_prem_exp : 'Благословение Абу-Бекра истекло',
  254. workaholic_penalty : 'Штраф трудоголика',
  255. workaholic_penalty_regexp : 'штраф трудоголика',
  256. regexp_sm : /Завершение работы: (\d+)-(\d+) (\d+):(\d+)/,
  257. st_start : 'Все изменения будут видны после перезагрузки страницы',
  258. st_null_timers : 'Обнулить все таймеры',
  259. st_gv_n_time : 'Единоразово установить таймер ГВ/ГРж равным',
  260. st_percent_faster : 'Задания ГО, ГН, ГВ, ГРж чаще на',
  261. st_gre_check : 'По прибытии вступать в бои Гильдии Рейнджеров',
  262. st_show_timers : '<b>Отображать:</b>',
  263. st_predupr_pa : '<b>Благословение Абу-Бекра</b> определяется автоматически',
  264. st_work_trudogolik_show : '<b>Показывать</b> штраф трудоголика только <b>за 2 часа</b>',
  265. st_work_trudogolik_off : '<b>Отключить</b> ВСЕ уведомления о штрафе трудоголика',
  266. st_predupr_go_lic : '<b>Лицензия охотника</b> определяется автоматически (в Гильдии Охотников)',
  267. st_go_timer_hide : '<b>Скрывать</b>',
  268. workaholic_text1 : ' примерно через ',
  269. workaholic_text2 : ' устройств',
  270. workaholic_text3 : ' на работу.',
  271. workaholic_text1_replace : ' <font color:"red">активен</font> примерно ',
  272. uze_ustroen : 'Вы уже устроены\.',
  273. uze_ustroen2 : 'Прошло меньше часа с последнего устройства на работу\. Ждите\.',
  274. uze_ustroen3 : 'Нет рабочих мест\.'
  275. };
  276. }
  277.  
  278. obj.regexp_time_server = /(\d+):(\d+), \d+ online/;
  279. obj.regexp_time_server2 = /(\d+):(\d+):(\d+), \d+ online/;
  280. obj.regexp_lic_mo = /(\d+)-(\d+)-(\d+) (\d+):(\d+)/;
  281. obj.regexp_prem = /(\d+)-(\d+)-(\d+) (\d+):(\d+)/;
  282. obj.sm_alert_tn = obj.work_alert_tn;
  283. obj.gn_alert_tn = obj.work_alert_tn;
  284. obj.go_alert_tn = obj.work_alert_tn;
  285. obj.gv_alert_tn = obj.work_alert_tn;
  286. obj.gre_alert_tn = obj.work_alert_tn;
  287. obj.gv_tit = '/thief_guild.php';
  288. obj.gre_tit = '/ranger_guild.php';
  289.  
  290. if (options["gv_or_gre"] == '1') {
  291. obj.alert_gv = obj.alert_gre;
  292. obj.gv_alert_ty = obj.gre_alert_ty;
  293. obj.gv_alert_tn = obj.gre_alert_tn;
  294. obj.gv_t = obj.gre_t;
  295. obj.gv_title = obj.gre_title;
  296. obj.gv_tit = obj.gre_tit;
  297. }
  298. return obj;
  299. }
  300.  
  301. function alertOnLicMo(){
  302. if (options["time_percent_lic_mo_title"]) {
  303. if (Number(options["time_percent_lic_mo_exp"]) > time_cur) {
  304. texts.go_title += '\n' + texts.go_title_lic + options["time_percent_lic_mo_title"];
  305. } else {
  306. // лицензия охотника истекла
  307. setTimeout(function() { prompt(texts.alert_go_lic_exp); }, 300);
  308. options["time_percent_lic_mo"] = '1';
  309. options["time_percent_lic_mo_exp"] = '1300000000000';
  310. options["time_percent_lic_mo_title"] = '';
  311. }
  312. }
  313. }
  314.  
  315. function createTopRow(){
  316. var d = document.createElement('div');
  317. d.setAttribute('style', 'position: absolute; margin: -26px 0px 0px -43px; text-align: center;');
  318. d.innerHTML =
  319. '<style>' +
  320. '.hwm_tb * {font-size: 11px; color: #f5c137;}' +
  321. '.hwm_tb_cell {border-collapse: collapse; background-color: #6b6b69;}' +
  322. '.hwm_tb_cell TD {padding: 0px;}' +
  323. '.cell_t {height: 3px; background: url(' + _i + 't_top_bkg' + _i_ + '.jpg);}' +
  324. '.cell_c {white-space: nowrap; height: 18px; background: url(' + _i + 't_com_bkg' + _i_ + '.jpg); font-weight: bold;}' +
  325. '.cell_b {height: 5px; background: url(' + _i + 't_bot_bkg' + _i_ + '.jpg); text-align: center;}' +
  326. '.cell_b IMG {width: 17px; height: 5px;}' +
  327. '</style>' +
  328. '<table cellpadding=0 cellspacing=0 align="center" class="hwm_tb" width=' + (x2.getBoundingClientRect().left - x1.getBoundingClientRect().left + 124) + 'px>' +
  329. '<tr height=26>' +
  330. '<td>' +
  331. '<table width="100%" cellpadding=0 cellspacing=0 style="background: url(' + _i + 't_bkg' + _i_ + '.jpg);">' +
  332. '<tr valign=middle align=center>' +
  333. '<td width=5 style="overflow: hidden;"><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26 style="margin:0px 0px 0px -4px;"></td>' +
  334. '<td width=44>' +
  335. '<table class="hwm_tb_cell">' +
  336. '<tr><td class="cell_t"></td></tr>' +
  337. '<tr>' +
  338. '<td class="cell_c" style="cursor:pointer" id="pers_h">00:00</td>' +
  339. '</tr>' +
  340. '<tr><td class="cell_b"><img src="' + _i + 't_center' + _i_ + '.jpg"></td></tr>' +
  341. '</table>' +
  342. '</td>' +
  343. '<td width=9><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26></td>' +
  344. '<td id="gr_show1">' +
  345. '<table class="hwm_tb_cell">' +
  346. '<tr><td class="cell_t"></td></tr>' +
  347. '<tr>' +
  348. '<td class="cell_c"><span style="cursor:pointer" id="a_pers_w">' + texts.gr_t + '</span>: <a href="javascript:void(0);" title="' + texts.gr_title + '" style="text-decoration: none;" id="pers_w">00:00</a></td>' +
  349. '</tr>' +
  350. '<tr><td class="cell_b"><img src="' + _i + 't_center' + _i_ + '.jpg"></td></tr>' +
  351. '</table>' +
  352. '</td>' +
  353. '<td id="gr_show2" width=9><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26></td>' +
  354. '<td id="gk_show1">' +
  355. '<table class="hwm_tb_cell">' +
  356. '<tr><td class="cell_t"></td></tr>' +
  357. '<tr>' +
  358. '<td class="cell_c"><span style="cursor:pointer" id="a_pers_sm">' + texts.gk_t + '</span>: <a href="/mod_workbench.php?type=repair" title="' + texts.gk_title + '" style="text-decoration: none;" id="pers_sm">00:00</a></td>' +
  359. '</tr>' +
  360. '<tr><td class="cell_b"><img src="' + _i + 't_center' + _i_ + '.jpg"></td></tr>' +
  361. '</table>' +
  362. '</td>' +
  363. '<td id="gk_show2" width=9><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26></td>' +
  364. '<td id="gn_show1">' +
  365. '<table class="hwm_tb_cell">' +
  366. '<tr><td class="cell_t"></td></tr>' +
  367. '<tr>' +
  368. '<td class="cell_c"><span style="cursor:pointer" id="a_pers_gn">' + texts.gn_t + '</span>: <a href="/mercenary_guild.php" title="' + texts.gn_title + '" style="text-decoration: none;" id="pers_gn">00:00</a></td>' +
  369. '</tr>' +
  370. '<tr><td class="cell_b"><img src="' + _i + 't_center' + _i_ + '.jpg"></td></tr>' +
  371. '</table>' +
  372. '</td>' +
  373. '<td id="gn_show2" width=9><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26></td>' +
  374. '<td id="go_show1">' +
  375. '<table class="hwm_tb_cell">' +
  376. '<tr><td class="cell_t"></td></tr>' +
  377. '<tr>' +
  378. '<td class="cell_c"><span style="cursor:pointer" id="a_pers_go">' + texts.go_t + '</span>: <a href="/hunter_guild.php" title="' + texts.go_title + '" style="text-decoration: none;" id="pers_go">00:00</a>' +
  379. '</td>' +
  380. '</tr>' +
  381. '<tr><td class="cell_b"><img src="' + _i + 't_center' + _i_ + '.jpg"></td></tr>' +
  382. '</table>' +
  383. '</td>' +
  384. '<td id="go_show2" width=9><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26></td>' +
  385. '<td id="gv_show1">' +
  386. '<table class="hwm_tb_cell">' +
  387. '<tr><td class="cell_t"></td></tr>' +
  388. '<tr>' +
  389. '<td class="cell_c"><span style="cursor:pointer" id="a_pers_gv">' + texts.gv_t + '</span>: <a href="' + texts.gv_tit + '" title="' + texts.gv_title + '" style="text-decoration: none;" id="pers_gv">00:00</a></td>' +
  390. '</tr>' +
  391. '<tr><td class="cell_b"><img src="' + _i + 't_center' + _i_ + '.jpg"></td></tr>' +
  392. '</table>' +
  393. '</td>' +
  394. '<td id="gv_show2" width=9><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26></td>' +
  395. '<td width=44>' +
  396. '<table class="hwm_tb_cell">' +
  397. '<tr><td class="cell_t"></td></tr>' +
  398. '<tr>' +
  399. '<td class="cell_c" style="cursor:pointer" id="pers_m" title="' + texts.mana_title + '">00:00</td>' +
  400. '</tr>' +
  401. '<tr><td class="cell_b"><img src="' + _i + 't_center' + _i_ + '.jpg"></td></tr>' +
  402. '</table>' +
  403. '</td>' +
  404. '<td width=5 style="overflow: hidden;"><img src="' + _i + 't_end' + _i_ + '.jpg" alt="" width=9 height=26 style="margin:0px -4px 0px 0px;"></td>' +
  405. '</tr>' +
  406. '</table>' +
  407. '</td>' +
  408. '</tr>' +
  409. '</table>';
  410. if (options["gr_show_check"] == '0') {
  411. d.querySelector("#gr_show1").style.display = d.querySelector("#gr_show2").style.display = 'none';
  412. }
  413. if (options["gk_show_check"] == '0') {
  414. d.querySelector("#gk_show1").style.display = d.querySelector("#gk_show2").style.display = 'none';
  415. }
  416. if (options["gn_show_check"] == '0') {
  417. d.querySelector("#gn_show1").style.display = d.querySelector("#gn_show2").style.display = 'none';
  418. }
  419. if (options["go_show_check"] == '0') {
  420. d.querySelector("#go_show1").style.display = d.querySelector("#go_show2").style.display = 'none';
  421. }
  422. if (options["gv_show_check"] == '0') {
  423. d.querySelector("#gv_show1").style.display = d.querySelector("#gv_show2").style.display = 'none';
  424. }
  425. x1.parentNode.appendChild(d);
  426. addEvent($("pers_m"), "click", settings);
  427. if (options["object_id"]) {
  428. setTimeout(function() {$("pers_w").href = "object-info.php?id=" + options["object_id"];}, 300);
  429. }
  430. return d;
  431. }
  432.  
  433. function loadServerTime(){
  434. // вычисление времени сервера (с поддержкой time_seconds)
  435. var t_server = texts.regexp_time_server2.exec(b.innerHTML);
  436. if (t_server) {
  437. return new Date(0, 0, 0, Number(t_server[1]), Number(t_server[2]), Number(t_server[3]));
  438. }
  439. t_server = texts.regexp_time_server.exec(b.innerHTML);
  440. if (t_server) {
  441. return new Date(0, 0, 0, Number(t_server[1]), Number(t_server[2]), 0);
  442. }
  443. }
  444.  
  445. function loadWorkEndTime(){
  446. if (location.pathname == '/home.php' && document.querySelector("img[src*='i/icons/attr_defense.png']")) {
  447. var t_gr, gr_temp;
  448. // подхватывание времени окончания работы с home.php и его проверка
  449. if (texts.time_home_time = texts.time_home.exec(b.innerHTML)) {
  450. t_gr = Number(texts.time_home_time[1]) * 60000; // в миллисекундах
  451. gr_temp = t_gr - Math.abs(Number(options["time_work_end"]) - time_cur);
  452. } else if ((texts.time_home_time = texts.time_home2.exec(b.innerHTML)) && time_server) {
  453. t_gr = new Date(0, 0, 0, Number(texts.time_home_time[1]), Number(texts.time_home_time[2]), 0);
  454. // example: 18:00 - 18:20 = - 20 мин уже работаю; -20 min + 60 min = 40 мин осталось'
  455. if (time_server < t_gr) {
  456. t_gr = t_gr - time_server + 60 * 60000 - 24 * 60 * 60000;
  457. } else { // в миллисекундах
  458. t_gr = t_gr - time_server + 60 * 60000;
  459. } // в миллисекундах
  460. gr_temp = t_gr - Math.abs(Number(options["time_work_end"]) - time_cur);
  461. }
  462. if (gr_temp && Math.abs(gr_temp) > 70000) {
  463. options["time_work_end"] = '' + (time_cur + t_gr);
  464. options["time_work_end_yes"] = 'no';
  465. }
  466. if (b.innerHTML.match(texts.work_unemployed)) {
  467. options["time_work_end"] = '1300000000000';
  468. options["time_work_end_yes"] = 'yes';
  469. }
  470. // проверка наличия эффекта блага АБУ Бекра (премиум аккаунт)
  471. var img_star_prem = document.querySelector("img[src$='i/star.gif']");
  472. if (img_star_prem) {
  473. img_star_prem.align = "absmiddle";
  474. options["time_percent_prem"] = '' + (70 / 100);
  475. var time_zone = 3 + new Date().getTimezoneOffset() / 60;
  476. if (new Date(2011, 0, 11).getTimezoneOffset() != new Date(2011, 6, 3).getTimezoneOffset()) time_zone += 1;
  477. // взять дату
  478. var time_server_day = new Date(Date.parse(new Date()) + time_zone * 60 * 60 * 1000);
  479. time_server_day = Date.parse(new Date(time_server_day.getFullYear(), time_server_day.getMonth(), time_server_day.getDate(), time_server.getHours(), time_server.getMinutes(), time_server.getSeconds()));
  480. var time_prem = texts.regexp_prem.exec(img_star_prem.title);
  481. if (time_prem) {
  482. if (url.match('lordswm')) {
  483. // 2013-05-31 23:25
  484. time_prem = Date.parse(new Date(Number(time_prem[1]), Number(time_prem[2]) - 1, Number(time_prem[3]), Number(time_prem[4]), Number(time_prem[5])));
  485. } else {
  486. // 31-05-13 23:25
  487. time_prem = Date.parse(new Date(Number(time_prem[3]) + 2000, Number(time_prem[2]) - 1, Number(time_prem[1]), Number(time_prem[4]), Number(time_prem[5])));
  488. }
  489. options["time_percent_prem_exp"] = '' + (time_cur + time_prem - time_server_day);
  490. options["time_percent_prem_title"] = img_star_prem.title;
  491. }
  492. } else {
  493. options["time_percent_prem"] = '1';
  494. options["time_percent_prem_exp"] = '1300000000000';
  495. if (options["time_percent_prem_title"]) {
  496. // эффекта блага АБУ Бекра (премиум аккаунт) - нет. (закончился)
  497. setTimeout(function() {
  498. prompt(texts.alert_prem_exp);
  499. }, 300);
  500. options["time_percent_prem_title"] = '';
  501. }
  502. }
  503. }
  504. }
  505.  
  506. function checkAbu(){
  507. if (options["time_percent_prem_title"]) {
  508. if (Number(options["time_percent_prem_exp"]) > time_cur) {
  509. texts.gr_title = options["time_percent_prem_title"];
  510. $('pers_w').title = texts.gr_title;
  511. } else {
  512. // эффекта блага АБУ Бекра (премиум аккаунт) - нет. (закончился)
  513. setTimeout(function() {prompt(texts.alert_prem_exp);}, 300);
  514. options["time_percent_prem"] = '1';
  515. options["time_percent_prem_exp"] = '1300000000000';
  516. options["time_percent_prem_title"] = '';
  517. }
  518. }
  519. }
  520.  
  521. function checkLicMoO(){
  522. var form_f2 = document.querySelector("form[name='f2']");
  523. if (location.pathname == '/hunter_guild.php' && time_server && form_f2) {
  524. while (form_f2.tagName != 'TR') {
  525. form_f2 = form_f2.parentNode;
  526. }
  527. if (texts.regexp_lic_mo.exec(form_f2.innerHTML)) {
  528. if (!form_f2.querySelector("input[type='submit'][onclick*='confirm']")) {
  529. // лицензия МО
  530. options["time_percent_lic_mo"] = '' + (50 / 100);
  531. } else {
  532. // лицензия О
  533. options["time_percent_lic_mo"] = '' + (75 / 100);
  534. }
  535. var time_zone = 3 + new Date().getTimezoneOffset() / 60;
  536. if (new Date(2011, 0, 11).getTimezoneOffset() != new Date(2011, 6, 3).getTimezoneOffset()) time_zone += 1;
  537. // взять дату
  538. var time_server_day = new Date(Date.parse(new Date()) + time_zone * 60 * 60 * 1000);
  539. time_server_day = Date.parse(new Date(time_server_day.getFullYear(), time_server_day.getMonth(), time_server_day.getDate(), time_server.getHours(), time_server.getMinutes(), time_server.getSeconds()));
  540. form_f2 = form_f2.querySelectorAll("td");
  541. var time_lic_mo_max = 0;
  542. for (var i = form_f2.length; i--;) {
  543. if (form_f2[i].innerHTML.indexOf("<td") != -1) {
  544. continue;
  545. }
  546. var time_lic_mo = texts.regexp_lic_mo.exec(form_f2[i].innerHTML);
  547. if (time_lic_mo) {
  548. var time_lic_exp;
  549. if (url.match('lordswm')) {
  550. // дата истечения срока 05-31-13 23:25
  551. time_lic_exp = Date.parse(new Date(Number(time_lic_mo[3]) + 2000, Number(time_lic_mo[1]) - 1, Number(time_lic_mo[2]), Number(time_lic_mo[4]), Number(time_lic_mo[5])));
  552. } else {
  553. // 31-05-13 23:25
  554. time_lic_exp = Date.parse(new Date(Number(time_lic_mo[3]) + 2000, Number(time_lic_mo[2]) - 1, Number(time_lic_mo[1]), Number(time_lic_mo[4]), Number(time_lic_mo[5])));
  555. }
  556. if (time_lic_exp > time_lic_mo_max) {
  557. time_lic_mo_max = time_lic_exp;
  558. options["time_percent_lic_mo_exp"] = '' + (time_cur + time_lic_mo_max - time_server_day);
  559. options["time_percent_lic_mo_title"] = time_lic_mo[0];
  560. }
  561. }
  562. }
  563. } else {
  564. options["time_percent_lic_mo"] = '1';
  565. options["time_percent_lic_mo_exp"] = '1300000000000';
  566. options["time_percent_lic_mo_title"] = '';
  567. }
  568. }
  569. }
  570.  
  571. function checkWar(){
  572. if (gm_get_bool("war_unload_" + location.hostname)) {
  573. var alt = "a";
  574. var bselect_link = document.querySelector("a[href='bselect.php']");
  575. if (!bselect_link) {
  576. bselect_link = document.querySelector("a[href='plstats.php']");
  577. }
  578. if (bselect_link && bselect_link.parentNode.innerHTML.indexOf("#ff0000") == -1) {
  579. gm_del("war_unload_" + location.hostname);
  580. alt += "11";
  581. if (options["map_thief_ambush"] == "true") {
  582. alt += "2";
  583. options["map_thief_ambush"] = 'false';
  584. if (army_percent < 100) {
  585. alt += "33";
  586. options["time_gv_end"] = '' + (time_cur + 60 * 60000 * options["time_percent_faster"] * options["time_percent_prem"]);
  587. options["time_gv_end_yes"] = 'no';
  588. } else {
  589. alt += "44";
  590. options["time_gv_end"] = '1300000000000';
  591. options["time_gv_end_yes"] = 'yes';
  592. }
  593. }
  594. if (options["map_hunter"] == "true") {
  595. alt += "56";
  596. options["map_hunter"] = 'false';
  597. options["time_go_end_yes"] = 'no';
  598. if (time_server && time_server.getHours() < 8) {
  599. options["time_go_end"] = '' + (time_cur + 20 * 60000 * options["time_percent_faster"] * options["time_percent_prem"] * options["time_percent_lic_mo"]);
  600. } else {
  601. options["time_go_end"] = '' + (time_cur + 40 * 60000 * options["time_percent_faster"] * options["time_percent_prem"] * options["time_percent_lic_mo"]);
  602. }
  603. }
  604. if (army_percent == 100) {
  605. alt += "7";
  606. options["time_work_trudogolik"] = '0';
  607. }
  608. }
  609. // if ( alt != "a" ) { setTimeout(function() { alert( alt ); }, 500); }
  610. }
  611. }
  612.  
  613. function checkJustWork(){
  614. if (location.pathname == '/object_do.php') {
  615. if (b.innerHTML.match(texts.work_obj_do)) {
  616. options["time_work_end"] = '' + (time_cur + 60 * 60000);
  617. options["time_work_end_yes"] = 'no';
  618. options["time_work_trudogolik"] = '' + (Number(options["time_work_trudogolik"]) + 1);
  619. var object_id = /id=(\d+)/.exec(url_cur);
  620. if (object_id) {
  621. options["object_id"] = '' + object_id[1];
  622. }
  623. }
  624. }
  625. }
  626.  
  627. function checkWork(){
  628. if (location.pathname == '/object-info.php') {
  629. var parent_trud = document.querySelector("a[href*='objectworkers.php']");
  630. if (parent_trud) {
  631. var regexp_workaholic = new RegExp('\\*\\&nbsp;0\\.(\\d) ' + texts.workaholic_penalty_regexp);
  632. // отработано смен
  633. var workaholic_WORK = Number(options["time_work_trudogolik"]);
  634. if (regexp_workaholic.exec(b.innerHTML)) {
  635. regexp_workaholic = Number(regexp_workaholic.exec(b.innerHTML)[1]);
  636. if (regexp_workaholic == 8) {
  637. workaholic_WORK = 11;
  638. } else if (regexp_workaholic == 6) {
  639. workaholic_WORK = 12;
  640. } else if (regexp_workaholic == 4) {
  641. workaholic_WORK = 13;
  642. } else if (regexp_workaholic == 2) {
  643. workaholic_WORK = 14;
  644. } else if (regexp_workaholic == 1 && workaholic_WORK < 15) {
  645. workaholic_WORK = 15;
  646. }
  647. options["time_work_trudogolik"] = '' + workaholic_WORK;
  648. } else if (workaholic_WORK > 10) {
  649. workaholic_WORK = 10;
  650. options["time_work_trudogolik"] = '' + workaholic_WORK;
  651. }
  652. var add_trud = document.createElement('span');
  653. if (workaholic_WORK == 9 || workaholic_WORK == 10) {
  654. // выделить цветом
  655. add_trud.setAttribute('style', 'color:red; font-weight:bold;');
  656. } else if (workaholic_WORK > 10) {
  657. texts.workaholic_text1 = texts.workaholic_text1_replace;
  658. }
  659. // осталось работать
  660. var workaholic_ENROLL = Math.abs(11 - workaholic_WORK);
  661. if (workaholic_WORK > 14) {
  662. workaholic_ENROLL = workaholic_ENROLL + '+';
  663. }
  664. // правильные окончания слов
  665. if (!url.match('lordswm')) {
  666. if (workaholic_WORK == 9 || workaholic_WORK == 8 || workaholic_WORK == 7) {
  667. texts.workaholic_text2 += '\u0430';
  668. } else if (workaholic_WORK == 10) {
  669. texts.workaholic_text2 += '\u043E';
  670. }
  671. }
  672. if (options["time_work_trudogolik_off"] == '0') {
  673. if (options["time_work_trudogolik_show"] == '1' && workaholic_WORK != 9 && workaholic_WORK != 10) {
  674. } else {
  675. add_trud.innerHTML = texts.workaholic_penalty + texts.workaholic_text1 + workaholic_ENROLL + texts.workaholic_text2 + texts.workaholic_text3;
  676. parent_trud = parent_trud.parentNode.previousSibling.previousSibling;
  677. parent_trud.parentNode.insertBefore(add_trud, parent_trud);
  678. }
  679. }
  680. // замена "Уже устроен"
  681. parent_trud = document.querySelector("a[href*='objectworkers.php']").parentNode.parentNode;
  682. if ((time_cur > Number(options["time_work_end"])) && (parent_trud.innerHTML.match(texts.uze_ustroen) || (texts.uze_ustroen = parent_trud.innerHTML.match(texts.uze_ustroen2)) || (texts.uze_ustroen = parent_trud.innerHTML.match(texts.uze_ustroen3)))) {
  683. parent_trud.innerHTML = parent_trud.innerHTML.replace(texts.uze_ustroen, '<style>@-webkit-keyframes blink {80% {opacity:0.0;}} @-moz-keyframes blink {80% {opacity:0.0;}} @-o-keyframes blink {80% {opacity:0.0;}} @keyframes blink {80% {opacity:0.0;}}</style><font color=blue style="-webkit-animation: blink 1s steps(1,end) 0s infinite; -moz-animation: blink 1s steps(1,end) 0s infinite; -o-animation: blink 1s steps(1,end) 0s infinite; animation: blink 1s steps(1,end) 0s infinite"><b>' + texts.uze_ustroen + '</b></font>');
  684. }
  685. }
  686. }
  687. if (workaholic_WORK = options["time_work_trudogolik"]) {
  688. if (texts.gr_title) texts.gr_title += '\n';
  689. texts.gr_title += texts.workaholic_penalty + ": " + (11 - Number(workaholic_WORK));
  690. var title_gr = $('pers_w');
  691. title_gr.title = texts.gr_title;
  692. if (options["time_work_trudogolik_off"] == '0' && workaholic_WORK > 10)
  693. title_gr.style.color = '#ff9c00';
  694. }
  695. }
  696. function checkMercenary(){
  697. if (location.pathname == '/mercenary_guild.php') {
  698. var time_gn;
  699. if (document.querySelector("a[href^='/mercenary_guild.php?action=accept']")) {
  700. options["time_gn_end"] = '1300000000000';
  701. options["time_gn_end_yes"] = 'yes';
  702. } else if ((time_gn = texts.regexp_timegn0.exec(b.innerHTML)) || (time_gn = texts.regexp_timegn1.exec(b.innerHTML)) || (time_gn = texts.regexp_timegn2.exec(b.innerHTML)) || (time_gn = texts.regexp_timegn3.exec(b.innerHTML)) || (time_gn = texts.regexp_timegn4.exec(b.innerHTML)) || (time_gn = texts.regexp_timegn5.exec(b.innerHTML))) {
  703. time_gn = Number(time_gn[1]);
  704. if (texts.regexp_timegn0.exec(b.innerHTML) && (time_gn == 19 || time_gn == 13)) time_gn++;
  705. time_gn = time_gn * 60000; // в миллисекундах
  706. var time_gn_temp = time_gn - Math.abs(Number(options["time_gn_end"]) - time_cur);
  707. if (Math.abs(time_gn_temp) > 70000) {
  708. var reputation_gn = texts.regexp_gn_rep.exec(b.innerHTML);
  709. reputation_gn = (40 - Number(reputation_gn[1]) * 2) * options["time_percent_faster"] * options["time_percent_prem"] * 60000;
  710. // в миллисекундах
  711. time_gn_temp = time_gn - reputation_gn;
  712. if (Math.abs(time_gn_temp) > 70000) {
  713. options["time_gn_end"] = '' + (time_cur + time_gn);
  714. options["time_gn_end_yes"] = 'no';
  715. } else {
  716. options["time_gn_end"] = '' + (time_cur + reputation_gn);
  717. options["time_gn_end_yes"] = 'no';
  718. }
  719. }
  720. }
  721. // options["grandma"] = '1';
  722. if (b.innerHTML.match('Вы получаете') || b.innerHTML.match('You receive')) {
  723. var flash_heart = document.querySelector("object > param[value*='mercenary.swf']");
  724. if (flash_heart) {
  725. var rand_f;
  726. if (new Date().getHours() == 23) {
  727. rand_f = "d8EWAZm.jpg";
  728. } else if (options["grandma"]) {
  729. var img_win = new Array("3xVyD9G.jpg", "rdc2phi.jpg", "4Sz0fZh.jpg", "EeSup0D.jpg", "cfqFars.jpg", "HCuDAHi.jpg", "pYaFMyE.jpg");
  730. rand_f = Math.floor(Math.random() * img_win.length);
  731. rand_f = img_win[rand_f];
  732. }
  733. if (rand_f) {
  734. flash_heart.parentNode.style.display = 'none';
  735. var add_el = document.createElement('img');
  736. add_el.height = "150";
  737. add_el.width = "150";
  738. add_el.src = "http://i.imgur.com/" + rand_f;
  739. flash_heart.parentNode.parentNode.appendChild(add_el);
  740. }
  741. }
  742. }
  743. }
  744. }
  745. function checkRangerGuild(){
  746. if (location.pathname == '/ranger_guild.php') {
  747. if (document.querySelector("a[href^='ranger_guild.php?action=accept']")) {
  748. options["map_thief_ambush"] = 'false';
  749. options["time_gv_end"] = '1300000000000';
  750. options["time_gv_end_yes"] = 'yes';
  751. options["gv_or_gre"] = '1';
  752. }
  753. var time_gv = texts.regexp_timegre.exec(b.innerHTML);
  754. if (time_gv) {
  755. time_gv = Number(time_gv[1]) * 60000; // в миллисекундах
  756. var time_gv_temp = time_gv - Math.abs(Number(options["time_gv_end"]) - time_cur);
  757. if (Math.abs(time_gv_temp) > 70000) {
  758. options["map_thief_ambush"] = 'false';
  759. options["time_gv_end"] = '' + (time_cur + time_gv);
  760. options["time_gv_end_yes"] = 'no';
  761. options["gv_or_gre"] = '1';
  762. }
  763. }
  764. }
  765. if (location.pathname == '/ranger_list.php') {
  766. var link_ranger_attack = document.querySelectorAll("a[href^='ranger_attack.php?join']");
  767. if (link_ranger_attack.length > 0) {
  768. options["map_thief_ambush"] = 'false';
  769. options["time_gv_end"] = '1300000000000';
  770. options["time_gv_end_yes"] = 'yes';
  771. options["gv_or_gre"] = '1';
  772. for (var i = link_ranger_attack.length; i--;) {
  773. addEvent(link_ranger_attack[i], "click", function(event) {
  774. updateOption("map_thief_ambush", 'true');
  775. });
  776. }
  777. }
  778. }
  779. }
  780. function checkModWorkebench(){
  781. //???
  782. if (location.pathname == '/mod_workbench.php' && time_server) {
  783. if (texts.regexp_sm.exec(b.innerHTML)) {
  784. var time_zone = 3 + new Date().getTimezoneOffset() / 60;
  785. if (new Date(2011, 0, 11).getTimezoneOffset() != new Date(2011, 6, 3).getTimezoneOffset()) time_zone += 1;
  786. // взять дату
  787. var time_server_day = new Date(Date.parse(new Date()) + time_zone * 60 * 60 * 1000);
  788. time_server_day = Date.parse(new Date(0, time_server_day.getMonth(), time_server_day.getDate(), time_server.getHours(), time_server.getMinutes(), time_server.getSeconds()));
  789. var all_td_mod = document.querySelectorAll("td");
  790. var t_sm_mass = [];
  791. for (var i = all_td_mod.length; i--;) {
  792. if (all_td_mod[i].innerHTML.indexOf("<td") != -1) {
  793. continue;
  794. }
  795. var time_sm = texts.regexp_sm.exec(all_td_mod[i].innerHTML);
  796. if (time_sm) {
  797. // 31-06 17:43
  798. time_sm = Date.parse(new Date(0, Number(time_sm[2]) - 1, Number(time_sm[1]), Number(time_sm[3]), Number(time_sm[4]), 0));
  799. t_sm_mass.push(time_sm - time_server_day);
  800. }
  801. }
  802. t_sm_mass.sort(function(a, b) {
  803. return a - b;
  804. });
  805. options["time_sm_end"] = '' + (time_cur + t_sm_mass[0] + 60000);
  806. options["time_sm_end_yes"] = 'no';
  807. } else {
  808. options["time_sm_end"] = '1300000000000';
  809. options["time_sm_end_yes"] = 'yes';
  810. }
  811. }
  812. }
  813.  
  814. function checkMap(){
  815. if (location.pathname == '/map.php') {
  816. checkMapThief();
  817. checkMapRanger();
  818. checkMapHunter();
  819. }
  820. }
  821.  
  822. function checkMapThief(){
  823. var thief_ambush_cancel = document.querySelector("a[href^='thief_ambush_cancel.php']");
  824. if (thief_ambush_cancel) {
  825. options["map_thief_ambush"] = 'true';
  826. options["time_gv_end"] = '1300000000000';
  827. options["time_gv_end_yes"] = 'yes';
  828. options["gv_or_gre"] = '0';
  829. addEvent(thief_ambush_cancel, "click", function(event) {
  830. updateOption("map_thief_ambush", 'false');
  831. });
  832. }
  833. if (document.querySelector("a[href='ecostat.php']")) {
  834. if (options["gv_or_gre"] == '0' && !thief_ambush_cancel) {
  835. options["map_thief_ambush"] = 'false';
  836. }
  837. if (options["gv_or_gre"] == '1' && !document.querySelector("a[href='ranger_guild.php']")) {
  838. options["map_thief_ambush"] = 'false';
  839. }
  840. }
  841. var form_thief_ambush = document.querySelector("form[action='thief_ambush.php']");
  842. if (form_thief_ambush) {
  843. options["map_thief_ambush"] = 'false';
  844. options["time_gv_end"] = '1300000000000';
  845. options["time_gv_end_yes"] = 'yes';
  846. options["gv_or_gre"] = '0';
  847. var input_form_thief_ambush = form_thief_ambush.querySelector("input[type='submit']");
  848. addEvent(input_form_thief_ambush, "click", function(event) {
  849. updateOption("map_thief_ambush", 'true');
  850. });
  851. }
  852. }
  853.  
  854. function checkMapRanger(){
  855. var form_ranger_attack = document.querySelector("form[action='ranger_attack.php']");
  856. if (form_ranger_attack) {
  857. options["map_thief_ambush"] = 'false';
  858. options["time_gv_end"] = '1300000000000';
  859. options["time_gv_end_yes"] = 'yes';
  860. options["gv_or_gre"] = '1';
  861. var input_form_ranger_attack = form_ranger_attack.querySelector("input[type='submit']");
  862. addEvent(input_form_ranger_attack, "click", function(event) {
  863. updateOption("map_thief_ambush", 'true');
  864. });
  865. if (options["gre_check"] == '1') {
  866. options["map_thief_ambush"] = 'true';
  867. setTimeout(function() {
  868. form_ranger_attack.submit();
  869. }, 500);
  870. }
  871. }
  872. }
  873.  
  874. function checkMapHunter(){
  875. var temp_nl = document.querySelectorAll("img[src*='map/nl']");
  876. if (temp_nl.length > 0 && !document.querySelector("img[src*='css/loading.gif']")) {
  877. options["map_hunter"] = 'false';
  878. options["time_go_end"] = '1310000000000';
  879. options["time_go_end_yes"] = 'yes';
  880. for (var i = temp_nl.length, temp_parent, temp_child; i--;) {
  881. temp_parent = temp_nl[i];
  882. while (temp_parent.tagName != 'TR') {
  883. temp_parent = temp_parent.parentNode;
  884. }
  885. if (temp_parent.parentNode.querySelector("a[href^='map.php?action=skip']")) break;
  886. temp_parent = temp_parent.nextSibling;
  887. temp_child = temp_parent.firstChild.innerHTML;
  888. temp_parent.innerHTML = '<td colspan="2" align="left" width="100%"><table border="0" width="100%"><tbody><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="center">' + temp_child + '</td><td align="right" valign="top"><a href="map.php?action=skip">' + (url.match('lordswm') ? "Pass by " : "Пройти мимо") + '</a>&nbsp;</td></tr></tbody></table></td>';
  889. }
  890. }
  891. if (b.innerHTML.match(texts.regexp_go_timer) && (delta2 = /Delta2 = (\d+)/.exec(b.innerHTML))) {
  892. options["map_hunter"] = 'false';
  893. options["time_go_end"] = '' + (time_cur + delta2[1] * 1000);
  894. options["time_go_end_yes"] = 'no';
  895. // + Copyright demin
  896. if (options["go_timer_hide"] == '1') {
  897. function inj_314() {
  898. window["Refresh2"] = function() {}
  899. var temp_314 = document.getElementById('next_ht');
  900. while (temp_314.tagName != 'TABLE') {
  901. temp_314 = temp_314.parentNode;
  902. }
  903. temp_314.parentNode.removeChild(temp_314.previousSibling);
  904. temp_314.parentNode.removeChild(temp_314.previousSibling);
  905. temp_314.parentNode.removeChild(temp_314);
  906. }
  907. var elem = document.createElement('script');
  908. elem.type = "text/javascript";
  909. elem.innerHTML = inj_314.toString() + "inj_314()";
  910. document.querySelector("head").appendChild(elem);
  911. }
  912. // - Copyright
  913. }
  914. var go_link_action_attack = document.querySelectorAll("a[href^='map.php?action=attack']");
  915. for (i = go_link_action_attack.length; i--;) {
  916. addEvent(go_link_action_attack[i], "click", function(event) {
  917. updateOption("map_hunter", 'true');
  918. });
  919. }
  920. var go_link_action_skip = document.querySelectorAll("a[href^='map.php?action=skip']");
  921. for (i = go_link_action_skip.length; i--;) {
  922. addEvent(go_link_action_skip[i], "click", function(event) {
  923. options = getOptions();
  924. options["time_go_end_yes"] = 'no';
  925. var time_cur_now = new Date().getTime();
  926. if (time_server && (new Date(time_server.getTime() + time_cur_now - time_cur).getHours()) < 8) {
  927. options["time_go_end"] = '' + (time_cur_now + 10 * 60000 * options["time_percent_faster"] * options["time_percent_prem"] * options["time_percent_lic_mo"] + 1000);
  928. } else {
  929. options["time_go_end"] = '' + (time_cur_now + 20 * 60000 * options["time_percent_faster"] * options["time_percent_prem"] * options["time_percent_lic_mo"] + 1000);
  930. }
  931. setOptions(options);
  932. });
  933. }
  934. var go_link_help = document.querySelectorAll("a[onclick^='return print_friends']");
  935. for (i = go_link_help.length; i--;) {
  936. addEvent(go_link_help[i], "click", function(event) {
  937. setTimeout(function() {
  938. go_link_help_click();
  939. }, 200);
  940. });
  941. }
  942. if (b.innerHTML.match(texts.regexp_map_go) && options["time_go_end"] == '1310000000000') {
  943. options["time_go_end_yes"] = 'no';
  944. var time_cur_now = new Date().getTime();
  945. if (time_server && (new Date(time_server.getTime() + time_cur_now - time_cur).getHours()) < 8) {
  946. options["time_go_end"] = '' + (time_cur_now + 10 * 60000 * options["time_percent_faster"] * options["time_percent_prem"] * options["time_percent_lic_mo"] + 1000);
  947. } else {
  948. options["time_go_end"] = '' + (time_cur_now + 20 * 60000 * options["time_percent_faster"] * options["time_percent_prem"] * options["time_percent_lic_mo"] + 1000);
  949. }
  950. }
  951. }
  952.  
  953. function addEvents(){
  954. var title_hl = $('pers_h');
  955. addEvent(title_hl, "click", function(event) {
  956. if (options["time_health_alert"] == 'yes') {
  957. updateOption("time_health_alert", 'no');
  958. title_hl.style.color = '#f5c137';
  959. title_hl.title = texts.health_alert_tn;
  960. } else {
  961. updateOption("time_health_alert", 'yes');
  962. title_hl.style.color = '#ff9c00';
  963. title_hl.title = texts.health_alert_ty;
  964. }
  965. });
  966. if (options["time_health_alert"] == 'yes') {
  967. title_hl.style.color = '#ff9c00';
  968. title_hl.title = texts.health_alert_ty;
  969. } else {
  970. title_hl.title = texts.health_alert_tn;
  971. }
  972. var title_gr = $('a_pers_w');
  973. addEvent(title_gr, "click", function(event) {
  974. if (options["time_work_alert"] == 'yes') {
  975. updateOption("time_work_alert", 'no');
  976. options = getOptions();
  977. title_gr.style.color = '#f5c137';
  978. title_gr.title = texts.work_alert_tn;
  979. } else {
  980. options = getOptions();
  981. updateOption("time_work_alert", 'yes');
  982. title_gr.style.color = '#FF0000';
  983. title_gr.title = texts.work_alert_ty;
  984. }
  985. });
  986. if (options["time_work_alert"] == 'yes') {
  987. title_gr.style.color = '#FF0000';
  988. title_gr.title = texts.work_alert_ty;
  989. } else {
  990. title_gr.title = texts.work_alert_tn;
  991. }
  992. var title_sm = $('a_pers_sm');
  993. addEvent(title_sm, "click", function(event) {
  994. if (options["time_sm_alert"] == 'yes') {
  995. updateOption("time_work_alert", 'no');
  996. title_sm.style.color = '#f5c137';
  997. title_sm.title = texts.sm_alert_tn;
  998. } else {
  999. updateOption("time_work_alert", 'yes');
  1000. title_sm.style.color = '#FF0000';
  1001. title_sm.title = texts.sm_alert_ty;
  1002. }
  1003. });
  1004. if (options["time_sm_alert"] == 'yes') {
  1005. title_sm.style.color = '#FF0000';
  1006. title_sm.title = texts.sm_alert_ty;
  1007. } else {
  1008. title_sm.title = texts.sm_alert_tn;
  1009. }
  1010. var title_gn = $('a_pers_gn');
  1011. addEvent(title_gn, "click", function(event) {
  1012. if (options["time_gn_alert"] == 'yes') {
  1013. updateOption("time_gn_alert", 'no');
  1014. title_gn.style.color = '#f5c137';
  1015. title_gn.title = texts.gn_alert_tn;
  1016. } else {
  1017. updateOption("time_gn_alert", 'yes');
  1018. title_gn.style.color = '#FF0000';
  1019. title_gn.title = texts.gn_alert_ty;
  1020. }
  1021. });
  1022. if (options["time_gn_alert"] == 'yes') {
  1023. title_gn.style.color = '#FF0000';
  1024. title_gn.title = texts.gn_alert_ty;
  1025. } else {
  1026. title_gn.title = texts.gn_alert_tn;
  1027. }
  1028. var title_go = $('a_pers_go');
  1029. addEvent(title_go, "click", function(event) {
  1030. if (options["time_go_alert"] == 'yes') {
  1031. updateOption("time_go_alert", 'no');
  1032. title_go.style.color = '#f5c137';
  1033. title_go.title = texts.go_alert_tn;
  1034. } else {
  1035. updateOption("time_go_alert", 'yes');
  1036. title_go.style.color = '#FF0000';
  1037. title_go.title = texts.go_alert_ty;
  1038. }
  1039. });
  1040. if (options["time_go_alert"] == 'yes') {
  1041. title_go.style.color = '#FF0000';
  1042. title_go.title = texts.go_alert_ty;
  1043. } else {
  1044. title_go.title = texts.go_alert_tn;
  1045. }
  1046. var title_gv = $('a_pers_gv');
  1047. addEvent(title_gv, "click", function(event) {
  1048. if (options["time_gv_alert"] == 'yes') {
  1049. updateOption("time_gv_alert", 'no');
  1050. title_gv.style.color = '#f5c137';
  1051. title_gv.title = texts.gv_alert_tn;
  1052. } else {
  1053. updateOption("time_gv_alert", 'yes');
  1054. title_gv.style.color = '#FF0000';
  1055. title_gv.title = texts.gv_alert_ty;
  1056. }
  1057. });
  1058. if (options["time_gv_alert"] == 'yes') {
  1059. title_gv.style.color = '#FF0000';
  1060. title_gv.title = texts.gv_alert_ty;
  1061. } else {
  1062. title_gv.title = texts.gv_alert_tn;
  1063. }
  1064. }
  1065. function showTimers(){
  1066. if (vh && vh.parentNode.innerHTML.match(/var time_heart=(\d+);/)) {
  1067. var heart_scale = RegExp.$1;
  1068. var time_l = Math.floor( ( heart_scale * 1000 / 100 ) * ( 100 - army_percent ) );
  1069. time.h = Math.floor( time_l / 1000 );
  1070. if ( army_percent < 100 )
  1071. showtime( 'h' );
  1072. }
  1073. var time_work_end = Number(options["time_work_end"]);
  1074. if (time_cur < time_work_end) {
  1075. time.w = time_work_end;
  1076. if (Math.floor((time_work_end - time_cur) / 1000) < 3601) {
  1077. showtime('w');
  1078. } else {
  1079. options["time_work_end"] = '1300000000000';
  1080. options["time_work_end_yes"] = 'yes';
  1081. }
  1082. } else {
  1083. options["time_work_end"] = '1300000000000';
  1084. options["time_work_end_yes"] = 'yes';
  1085. }
  1086. var time_sm_end = Number(options["time_sm_end"])
  1087. if (time_cur < time_sm_end) {
  1088. time.sm = Math.floor((time_sm_end - time_cur) / 1000);
  1089. showtime('sm');
  1090. } else {
  1091. options["time_sm_end"] = '1300000000000';
  1092. options["time_sm_end_yes"] = 'yes';
  1093. }
  1094. var time_gn_end = Number(options["time_gn_end"]);
  1095. if (time_cur < time_gn_end) {
  1096. time.gn = Math.floor((time_gn_end - time_cur) / 1000);
  1097. if (time.gn < 54000) {
  1098. showtime('gn');
  1099. } else {
  1100. options["time_gn_end"] = '1300000000000';
  1101. options["time_gn_end_yes"] = 'yes';
  1102. }
  1103. } else {
  1104. options["time_gn_end"] = '1300000000000';
  1105. options["time_gn_end_yes"] = 'yes';
  1106. }
  1107. var time_go_end = Number(options["time_go_end"]);
  1108. if (time_cur < time_go_end) {
  1109. time.go = Math.floor((time_go_end - time_cur) / 1000);
  1110. if (time.go < 2401) {
  1111. showtime('go');
  1112. } else {
  1113. options["time_go_end"] = '1300000000000';
  1114. options["time_go_end_yes"] = 'yes';
  1115. }
  1116. }
  1117. // else { options["time_go_end"] = '1300000000000'; options["time_go_end_yes"] = 'yes'; }
  1118. var time_gv_end = Number(options["time_gv_end"]);
  1119. if (time_cur < time_gv_end) {
  1120. time.gv = Math.floor((time_gv_end - time_cur) / 1000);
  1121. if (time.gv < 3601) {
  1122. showtime('gv');
  1123. } else {
  1124. options["time_gv_end"] = '1300000000000';
  1125. options["time_gv_end_yes"] = 'yes';
  1126. }
  1127. } else {
  1128. options["time_gv_end"] = '1300000000000';
  1129. options["time_gv_end_yes"] = 'yes';
  1130. }
  1131. }
  1132.  
  1133. //user_7146446_hwmtimerestore
  1134. //92571_7173493_hwmtimerestore
  1135. function convertOptions(){
  1136. if(gm_get("converted")){
  1137. return false;
  1138. } else {
  1139. var debug = '--------------------<br/>Converting stored options / Перезаписываем сохранённые настройки<br/><br/>';
  1140. var keys = GM_listValues();
  1141. for ( var i = 0, len = keys.length; i < len; ++i ) {
  1142. var old_key = keys[i];
  1143. var curr_key, new_key, val, opt_notify_beg, opts_beg;
  1144. if(old_key.indexOf("user_")==0){
  1145. curr_key = old_key.substring("user_".length);
  1146. } else if(old_key.indexOf("92571_")==0) {
  1147. curr_key = old_key.substring("92571_".length);
  1148. } else if(old_key.indexOf("htr_")==0) {
  1149. if(old_key.indexOf("htr_92571_")==0 || old_key.indexOf("htr_user_")==0 || old_key.indexOf("htr_converted_")==0 || old_key.indexOf("__options")>-1 ) {
  1150. debug += delete_option(old_key);
  1151. continue;
  1152. } else if(old_key.indexOf("options") > -1 && old_key.indexOf("_options") == -1 ) {
  1153. debug += delete_option(old_key);
  1154. continue;
  1155. } else {
  1156. debug += log_option_change('Already converted option', old_key, GM_getValue(old_key));
  1157. continue;
  1158. }
  1159. } else {
  1160. debug += log_option_change('Unknown option', old_key, GM_getValue(old_key));
  1161. continue;
  1162. }
  1163.  
  1164. // "92571_hwm_war_unload_"+location.hostname
  1165. if(curr_key.indexOf("hwm_war_unload_")==0){
  1166. new_key = curr_key.substring("hwm_".length);
  1167. val = GM_getValue(old_key);
  1168. if(val){
  1169. debug += convert_option(old_key, new_key, val=='true');
  1170. }
  1171. } else if ((opt_notify_beg = curr_key.indexOf("hwmtimerestore_r_notify")) > -1){
  1172. new_key = curr_key.substring(0, opt_notify_beg)+'_notify';
  1173. debug += convert_option(old_key, new_key);
  1174. } else if ((opts_beg = curr_key.indexOf("hwmtimerestore")) > -1){
  1175. val = GM_getValue(old_key);
  1176. if(val){
  1177. new_key = curr_key.substring(0, opts_beg);
  1178. if(new_key.charAt(new_key.length-1) != '_')
  1179. new_key += '_';
  1180. new_key += 'options';
  1181. debug += convert_option(old_key, new_key, val.replace(/hwm_/g,''));
  1182. }
  1183. }
  1184. }
  1185. document.body.innerHTML = debug;
  1186. gm_set("converted");
  1187. return true;
  1188. }
  1189. }
  1190.  
  1191. function delete_option(key){
  1192. var result = log_option_change('deleted', key, GM_getValue(key));
  1193. GM_deleteValue(key);
  1194. return result;
  1195. }
  1196.  
  1197. function convert_option(old_key, new_key, new_val){
  1198. var val = GM_getValue(old_key);
  1199. var result = '';
  1200. if(val){
  1201. gm_set(new_key, new_val ? new_val : val);
  1202. result = log_option_change('added', gm_prefix+new_key, gm_get(new_key));
  1203. }
  1204. result += delete_option(old_key);
  1205. return result;
  1206. }
  1207.  
  1208. function log_option_change(op, key, val){
  1209. return '<i><b>'+op+'</b></i>: [<b>'+key+"</b>:"+val+']<br/>';
  1210. }
  1211.  
  1212. function getPlayerId(){
  1213. var hunter_ref = getI("//a[contains(@href, 'pl_hunter_stat')]").snapshotItem(0);
  1214. if(hunter_ref)
  1215. return hunter_ref.href.split('?id=')[1];
  1216. }
  1217.  
  1218. function signal(msg){
  1219. var notify_type = gm_get(pl_id + "_notify", '0');
  1220. if(notify_type=='1'){
  1221. alert( msg );
  1222. } else if(notify_type=='2'){
  1223. audio.play();
  1224. alert( msg );
  1225. } else {
  1226. audio.play();
  1227. }
  1228. }
  1229.  
  1230. function showtime(t) {
  1231. var el = $('pers_' + t);
  1232. var ct;
  1233. if (t == 'h') {
  1234. ct = --time.h;
  1235. } else if (t == 'm') {
  1236. ct = --time.m;
  1237. } else if (t == 'w') {
  1238. ct = Math.floor((time.w - new Date().getTime()) / 1000);
  1239. } else if (t == 'gn') {
  1240. ct = --time.gn;
  1241. } else if (t == 'go') {
  1242. ct = --time.go;
  1243. } else if (t == 'sm') {
  1244. ct = --time.sm;
  1245. } else if (t == 'gv') {
  1246. ct = --time.gv;
  1247. }
  1248. if(ct < 0)
  1249. ct = 0;
  1250. var dd = Math.floor(ct / 86400);
  1251. var dh = Math.floor((ct - dd * 86400) / 3600);
  1252. var dm = Math.floor((ct - dd * 86400 - dh * 3600) / 60);
  1253. var ds = ct % 60;
  1254. el.innerHTML = (dd == 0 ? '' : ((dd < 10) ? '0' : '') + dd + ':') + (dd == 0 && dh == 0 ? '' : ((dh < 10) ? '0' : '') + dh + ':') + ((dm < 10) ? '0' : '') + dm + ':' + ((ds < 10) ? '0' : '') + ds;
  1255. if (ct == 0) {
  1256. options = getOptions();
  1257. if (t == 'h') {
  1258. title_hl.style.color = '#f5c137';
  1259. title_hl.title = health_alert_tn;
  1260. if (options["time_health_alert"] == 'yes') {
  1261. options["time_health_alert"] = 'no';
  1262. setTimeout(function() {signal(texts.alert_health);}, 100);
  1263. }
  1264. }
  1265. if (t == 'w' && options["time_work_end_yes"] != 'yes' && options["time_work_alert"] == 'yes') {
  1266. options["time_work_end_yes"] = 'yes';
  1267. setTimeout(function() {signal(texts.alert_work);}, 100);
  1268. }
  1269. if (t == 'sm' && options["time_sm_end_yes"] != 'yes' && options["time_sm_alert"] == 'yes') {
  1270. options["time_sm_end_yes"] = 'yes';
  1271. setTimeout(function() {signal(texts.alert_sm);}, 100);
  1272. }
  1273. if (t == 'gn' && options["time_gn_end_yes"] != 'yes' && options["time_gn_alert"] == 'yes') {
  1274. options["time_gn_end_yes"] = 'yes';
  1275. setTimeout(function() {signal(texts.alert_gn);}, 100);
  1276. }
  1277. if (t == 'go' && options["time_go_end_yes"] != 'yes' && options["time_go_alert"] == 'yes') {
  1278. options["time_go_end_yes"] = 'yes';
  1279. setTimeout(function() {signal(texts.alert_go);}, 100);
  1280. }
  1281. if (t == 'gv' && options["time_gv_end_yes"] != 'yes' && options["time_gv_alert"] == 'yes') {
  1282. options["time_gv_end_yes"] = 'yes';
  1283. setTimeout(function() {signal(texts.alert_gv);}, 100);
  1284. }
  1285. setOptions(options);
  1286. return;
  1287. }
  1288. if (ct < 0) {
  1289. el.innerHTML = '00:00';
  1290. return;
  1291. }
  1292. setTimeout(function() {
  1293. showtime(t)
  1294. }, 999);
  1295. }
  1296.  
  1297.  
  1298. function settings_close() {
  1299. var bg = $('bgOverlay');
  1300. var bgc = $('bgCenter');
  1301. bg.parentNode.removeChild(bg);
  1302. bgc.parentNode.removeChild(bgc);
  1303. }
  1304.  
  1305. function settings() {
  1306. var bg = $('bgOverlay');
  1307. var bgc = $('bgCenter');
  1308. var bg_height = ScrollHeight();
  1309. if (!bg) {
  1310. bg = document.createElement('div');
  1311. document.body.appendChild(bg);
  1312. bgc = document.createElement('div');
  1313. document.body.appendChild(bgc);
  1314. }
  1315. bg.id = 'bgOverlay';
  1316. bg.style.position = 'absolute';
  1317. bg.style.left = '0px';
  1318. bg.style.width = '100%';
  1319. bg.style.background = "#000000";
  1320. bg.style.opacity = "0.5";
  1321. bg.style.zIndex = "1100";
  1322. bgc.id = 'bgCenter';
  1323. bgc.style.position = 'absolute';
  1324. bgc.style.left = ((ClientWidth() - 650) / 2) + 'px';
  1325. bgc.style.width = '680px';
  1326. bgc.style.background = "#F6F3EA";
  1327. bgc.style.zIndex = "1105";
  1328. addEvent(bg, "click", settings_close);
  1329.  
  1330. options = getOptions();
  1331. bgc.innerHTML = '<div style="border:3px solid #abc; padding:10px; margin:2px; ">' +
  1332. '<div style="float:right; border:1px solid #abc; width:15px; height:15px; text-align:center; cursor:pointer; " id="bt_close_tr" title="Close">x</div><table>' +
  1333. '<tr><td><center><b><b style="text-decoration: none; color: #1199FF;"> Настройки. ТАЙМЕРЫ ГИЛЬДИЙ. </b>' + ' Автор: <b><a href="pl_info.php?id=15091">Demin</a></b> <a href="javascript:void(0);" id="open_transfer_id"> *</a></center></td></tr>'+
  1334. '<tr><td align="center"> <b>' + texts.st_start + '</b> </td>' +
  1335. '<tr><td>' + texts.st_show_timers + '&nbsp;&nbsp;' + texts.gr_t + ':<input type=checkbox ' + (options["gr_show_check"] == "1" ? "checked" : "") + ' id=hwm_gr_show_check_id title="">' +
  1336. '&nbsp;&nbsp;' + texts.gk_t + ':<input type=checkbox ' + (options["gk_show_check"] == "1" ? "checked" : "") + ' id=hwm_gk_show_check_id title="">' +
  1337. '&nbsp;&nbsp;' + texts.gn_t + ':<input type=checkbox ' + (options["gn_show_check"] == "1" ? "checked" : "") + ' id=hwm_gn_show_check_id title="">' +
  1338. '&nbsp;&nbsp;' + texts.go_t + ':<input type=checkbox ' + (options["go_show_check"] == "1" ? "checked" : "") + ' id=hwm_go_show_check_id title="">' +
  1339. '&nbsp;&nbsp;' + texts.gv_t + ' (' + texts.gre_t + ')' + ':<input type=checkbox ' + (options["gv_show_check"] == "1" ? "checked" : "") + ' id=hwm_gv_show_check_id title=""></td></tr>' +
  1340. '<tr><td>' + texts.st_gre_check + ': <input type=checkbox ' + (options["gre_check"] == "1" ? "checked" : "") + ' id=hwm_gre_check_id title=""></td></tr>' +
  1341. '<tr><td>' + texts.st_go_timer_hide + ' "<i>' + texts.regexp_go_timer + ' ..</i>": <input type=checkbox ' + (options["go_timer_hide"] == "1" ? "checked" : "") + ' id=hwm_go_timer_hide_id title=""></td></tr>' +
  1342. '<tr><td>' + texts.st_work_trudogolik_off + ': <input type=checkbox ' + (options["time_work_trudogolik_off"] == "1" ? "checked" : "") + ' id=hwm_trudogolik_off_id title=""></td></tr>' +
  1343. '<tr><td>' + texts.st_work_trudogolik_show + ': <input type=checkbox ' + (options["time_work_trudogolik_show"] == "1" ? "checked" : "") + ' id=hwm_trudogolik_show_id title=""></td></tr>' +
  1344. '<tr><td>' + texts.st_predupr_pa + '</td></tr>' +
  1345. '<tr><td>' + texts.st_predupr_go_lic + '</td></tr>' +
  1346. '<tr><td>' + texts.st_percent_faster + ' <input id="gv_n_percent" value="' +
  1347. (100 - options["time_percent_faster"] * 100) +
  1348. '" style="width: 25px;" maxlength="2"> <b>%</b> <input type="submit" id="gv_n_percent_ok" value="ok"></td></tr>' +
  1349. '<tr><td>' + texts.st_gv_n_time + ' <input id="gv_n_time" value="' +
  1350. (60 * options["time_percent_faster"] * options["time_percent_prem"]) +
  1351. '" style="width: 25px;" maxlength="2"> <b>min</b> <input type="submit" id="gv_n_time_ok" value="ok"></td></tr>' +
  1352. '<tr><td> <input type="submit" id="null_tr_id" value="' + texts.st_null_timers + '">&nbsp;&nbsp;&nbsp;' +
  1353. '</td></tr>' +
  1354. '<tr><td>'+
  1355. '<b>Режим оповещения</b> окончания таймера: <input type="radio" name="r_notify_type" id="r_notify_0">audio'+
  1356. '<input type="radio" name="r_notify_type" id="r_notify_1">alarm' +
  1357. '<input type="radio" name="r_notify_type" id="r_notify_2">alarm+audio' +
  1358. '</td></tr></td></tr>' +
  1359. '<tr><td>Audio file: <input size=55 type="text" id="audio_file" value="' + (options["time_audio_file"] ? options["time_audio_file"] : '') + '"> <input size=55 type="button" id="play_audio" value="Play!"> </td></tr>' +
  1360. '</table><table width=100%>' +
  1361. '</table></div>';
  1362. addEvent($("bt_close_tr"), "click", settings_close);
  1363. addEvent($("null_tr_id"), "click", null_tr);
  1364. addEvent($("gv_n_time_ok"), "click", gv_n_time_f);
  1365. addEvent($("gv_n_percent_ok"), "click", gv_n_percent_f);
  1366. addEvent($("hwm_gre_check_id"), "click", check_gre_f);
  1367. addEvent($("hwm_trudogolik_show_id"), "click", hwm_trudogolik_show_f);
  1368. addEvent($("hwm_trudogolik_off_id"), "click", hwm_trudogolik_off_f);
  1369. addEvent($("hwm_go_timer_hide_id"), "click", hwm_go_timer_hide_f);
  1370. addEvent($("hwm_gr_show_check_id"), "click", hwm_gr_show_check_id_f);
  1371. addEvent($("hwm_gk_show_check_id"), "click", hwm_gk_show_check_id_f);
  1372. addEvent($("hwm_gn_show_check_id"), "click", hwm_gn_show_check_id_f);
  1373. addEvent($("hwm_go_show_check_id"), "click", hwm_go_show_check_id_f);
  1374. addEvent($("hwm_gv_show_check_id"), "click", hwm_gv_show_check_id_f);
  1375. addEvent($("audio_file"), "change", change_audio);
  1376. addEvent($("play_audio"), "click", play_audio);
  1377. addEvent($("r_notify_0"), "click", hwm_set_notify_type);
  1378. addEvent($("r_notify_1"), "click", hwm_set_notify_type);
  1379. addEvent($("r_notify_2"), "click", hwm_set_notify_type);
  1380. bg.style.top = '0px';
  1381. bg.style.height = bg_height + 'px';
  1382. bgc.style.top = (window.pageYOffset + 150) + 'px';
  1383. bg.style.display = '';
  1384. bgc.style.display = '';
  1385.  
  1386. var notify_type = gm_get(pl_id + "_notify", 0);
  1387. var radioNotify = $('r_notify_'+notify_type);
  1388. if(!radioNotify)
  1389. radioNotify = $('r_notify_0');
  1390. radioNotify.checked=true;
  1391. }
  1392.  
  1393. function change_audio(){
  1394. updateOption("time_audio_file", this.value);
  1395. }
  1396. function play_audio(){
  1397. var paudio = new Audio();
  1398. paudio.preload = 'auto';
  1399. paudio.src = options["time_audio_file"];
  1400. audio.play();
  1401. }
  1402. function hwm_set_notify_type(e) {
  1403. var checked_radio;
  1404. if (e.target.checked) {
  1405. checked_radio = e.target.getAttribute('id');;
  1406. var notify_type = checked_radio? checked_radio.split('_')[2] : '';
  1407. if(checked_radio){
  1408. gm_set(pl_id + "_notify", notify_type);
  1409. }
  1410. }
  1411. }
  1412.  
  1413. function gv_n_time_f() {
  1414. if (Number($("gv_n_time").value) >= 0) {
  1415. options = getOptions();
  1416. options["time_gv_end"] = '' + ((new Date()).getTime() + $("gv_n_time").value * 60000);
  1417. options["time_gv_end_yes"] = 'no';
  1418. setOptions(options);
  1419. }
  1420. }
  1421.  
  1422. function gv_n_percent_f() {
  1423. if (Number($("gv_n_percent").value) >= 0) {
  1424. options = getOptions();
  1425. options["time_percent_faster"] = '' + ((100 - $("gv_n_percent").value) / 100);
  1426. $("gv_n_time").value = (60 * options["time_percent_faster"] * options["time_percent_prem"]);
  1427. setOptions(options);
  1428. }
  1429. }
  1430.  
  1431. function go_link_help_click() {
  1432. var form_go_link_help = document.querySelectorAll("form[action='/map.php']");
  1433. for (var i = form_go_link_help.length; i--;) {
  1434. var input_form_go_link_help = form_go_link_help[i].querySelector("input[type='submit']");
  1435. addEvent(input_form_go_link_help, "click", function(event) {
  1436. updateOption("map_hunter", 'true');
  1437. });
  1438. }
  1439. }
  1440.  
  1441. function null_tr() { // обнуление всех таймеров
  1442. var temp = getOptions();
  1443. temp["time_work_end"] = 1300000000000;
  1444. temp["time_sm_end"] = 1300000000000;
  1445. temp["time_gn_end"] = 1300000000000;
  1446. temp["time_go_end"] = 1300000000000;
  1447. temp["time_gv_end"] = 1300000000000;
  1448. temp["time_thief_end"] = 1300000000000;
  1449. // temp["time_audio_file"] = "https://www.soundjay.com/button/button-1.wav";
  1450. setOptions(temp);
  1451. }
  1452.  
  1453. function save_check(field, key){
  1454. updateOption(key, $(field).checked ? '1' : '0');
  1455. }
  1456. function check_gre_f() {
  1457. save_check('hwm_gre_check_id', "hwm_gre_check");
  1458. }
  1459.  
  1460. function hwm_trudogolik_show_f() {
  1461. save_check('hwm_trudogolik_show_id', "hwm_time_work_trudogolik_show");
  1462. }
  1463.  
  1464. function hwm_trudogolik_off_f() {
  1465. save_check('hwm_trudogolik_off_id', "hwm_time_work_trudogolik_off");
  1466. }
  1467.  
  1468. function hwm_go_timer_hide_f() {
  1469. save_check('hwm_go_timer_hide_id', "hwm_go_timer_hide");
  1470. }
  1471.  
  1472. function hwm_gr_show_check_id_f() {
  1473. options = getOptions();
  1474. if ($('hwm_gr_show_check_id').checked == true) {
  1475. options["gr_show_check"] = '1';
  1476. $("gr_show1").style.display = $("gr_show2").style.display = '';
  1477. } else {
  1478. options["gr_show_check"] = '0';
  1479. var title_gr = $('a_pers_w');
  1480. options["time_work_alert"] = 'no';
  1481. title_gr.style.color = '#f5c137';
  1482. title_gr.title = texts.work_alert_tn;
  1483. $("gr_show1").style.display = $("gr_show2").style.display = 'none';
  1484. }
  1485. setOptions(options);
  1486. }
  1487.  
  1488. function hwm_gk_show_check_id_f() {
  1489. options = getOptions();
  1490. if ($('hwm_gk_show_check_id').checked == true) {
  1491. options["gk_show_check"] = '1';
  1492. $("gk_show1").style.display = $("gk_show2").style.display = '';
  1493. } else {
  1494. options["gk_show_check"] = '0';
  1495. var title_sm = $('a_pers_sm');
  1496. options["time_sm_alert"] = 'no';
  1497. title_sm.style.color = '#f5c137';
  1498. title_sm.title = texts.sm_alert_tn;
  1499. $("gk_show1").style.display = $("gk_show2").style.display = 'none';
  1500. }
  1501. setOptions(options);
  1502. }
  1503.  
  1504. function hwm_gn_show_check_id_f() {
  1505. options = getOptions();
  1506. if ($('hwm_gn_show_check_id').checked == true) {
  1507. options["gn_show_check"] = '1';
  1508. $("gn_show1").style.display = $("gn_show2").style.display = '';
  1509. } else {
  1510. options["gn_show_check"] = '0';
  1511. var title_gn = $('a_pers_gn');
  1512. options["time_gn_alert"] = 'no';
  1513. title_gn.style.color = '#f5c137';
  1514. title_gn.title = texts.gn_alert_tn;
  1515. $("gn_show1").style.display = $("gn_show2").style.display = 'none';
  1516. }
  1517. setOptions(options);
  1518. }
  1519.  
  1520. function hwm_go_show_check_id_f() {
  1521. options = getOptions();
  1522. if ($('hwm_go_show_check_id').checked == true) {
  1523. options["go_show_check"] = '1';
  1524. $("go_show1").style.display = $("go_show2").style.display = '';
  1525. } else {
  1526. options["go_show_check"] = '0';
  1527. var title_go = $('a_pers_go');
  1528. options["time_go_alert"] = 'no';
  1529. title_go.style.color = '#f5c137';
  1530. title_go.title = texts.go_alert_tn;
  1531. $("go_show1").style.display = $("go_show2").style.display = 'none';
  1532. }
  1533. setOptions(options);
  1534. }
  1535.  
  1536. function hwm_gv_show_check_id_f() {
  1537. options = getOptions();
  1538. if ($('hwm_gv_show_check_id').checked == true) {
  1539. options["gv_show_check"] = '1';
  1540. $("gv_show1").style.display = $("gv_show2").style.display = '';
  1541. } else {
  1542. options["gv_show_check"] = '0';
  1543. var title_gv = $('a_pers_gv');
  1544. options["time_gv_alert"] = 'no';
  1545. title_gv.style.color = '#f5c137';
  1546. title_gv.title = texts.gv_alert_tn;
  1547. $("gv_show1").style.display = $("gv_show2").style.display = 'none';
  1548. }
  1549. setOptions(options);
  1550. }
  1551.  
  1552. function ClientHeight() {
  1553. return document.compatMode=='CSS1Compat' && document.documentElement?document.documentElement.clientHeight:document.body.clientHeight;
  1554. }
  1555.  
  1556. function ClientWidth() {
  1557. return document.compatMode=='CSS1Compat' && document.documentElement?document.documentElement.clientWidth:document.body.clientWidth;
  1558. }
  1559.  
  1560. function ScrollHeight() {
  1561. return Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);
  1562. }
  1563.  
  1564. function $(id) {
  1565. return document.querySelector("#" + id);
  1566. }
  1567.  
  1568. function addEvent(elem, evType, fn) {
  1569. if (elem.addEventListener) {
  1570. elem.addEventListener(evType, fn, false);
  1571. }
  1572. else if (elem.attachEvent) {
  1573. elem.attachEvent("on" + evType, fn);
  1574. }
  1575. else {
  1576. elem["on" + evType] = fn;
  1577. }
  1578. }
  1579.  
  1580. function initGm(){
  1581. if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
  1582. this.GM_getValue=function (key,def) {
  1583. return localStorage[key] || def;
  1584. };
  1585. this.GM_setValue=function (key,value) {
  1586. return localStorage[key]=value;
  1587. };
  1588. this.GM_deleteValue=function (key) {
  1589. return delete localStorage[key];
  1590. };
  1591. }
  1592. if (!this.GM_listValues || (this.GM_listValues.toString && this.GM_listValues.toString().indexOf("not supported")>-1)) {
  1593. this.GM_listValues=function () {
  1594. var keys=[];
  1595. for (var key in localStorage){
  1596. keys.push(key);
  1597. }
  1598. return keys;
  1599. }
  1600. }
  1601. }
  1602.  
  1603. function GM_get_once(key, def){
  1604. var val = GM_getValue(key, def);
  1605. GM_deleteValue(key);
  1606. return val;
  1607. }
  1608.  
  1609. function GM_load_num(key, def){
  1610. var val = Number(GM_getValue(key, def));
  1611. return isNaN(val) ? def : val;
  1612. }
  1613.  
  1614. // 1 -> true; otherwise false
  1615. function GM_load_bool_from_num(key){
  1616. var val = Number(GM_getValue(key, 0));
  1617. return isNaN(val) ? false : val==1;
  1618. }
  1619.  
  1620. // true -> 1; otherwise 0
  1621. function GM_save_num_from_bool(key, val){
  1622. GM_setValue(key, val ? 1 : 0);
  1623. }
  1624.  
  1625. function gm_get(key, def){
  1626. return GM_getValue(gm_prefix+key, def);
  1627. }
  1628.  
  1629. function gm_set(key, val){
  1630. return GM_setValue(gm_prefix+key, val);
  1631. }
  1632.  
  1633. function gm_set_bool(key, val){
  1634. return GM_save_num_from_bool(gm_prefix+key, val);
  1635. }
  1636.  
  1637. function gm_get_bool(key, val){
  1638. return GM_load_bool_from_num(gm_prefix+key);
  1639. }
  1640.  
  1641. function gm_del(key){
  1642. var val = GM_getValue(gm_prefix+key);
  1643. GM_deleteValue(gm_prefix+key);
  1644. return val;
  1645. }
  1646.  
  1647. function gm_list(){
  1648. var keys = GM_listValues();
  1649. var filtered = [];
  1650. for ( var i = 0, len = keys.length; i < len; i++ ) {
  1651. var key = keys[i];
  1652. if(key.indexOf(gm_prefix) == 0)
  1653. filtered.push(key);
  1654. }
  1655. return filtered;
  1656. }
  1657.  
  1658. function getI(xpath,elem){return document.evaluate(xpath,(!elem?document:elem),null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);}
  1659.  
  1660. })();
  1661. }catch(e){console.log(e); alert('hwm_time_restore: '+e);}