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