hwm_time_restore

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

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

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