hwm_time_restore

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

目前為 2018-11-25 提交的版本,檢視 最新版本

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