HWM-UI-UX-MOD

try to take over the world!

当前为 2021-02-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name HWM-UI-UX-MOD
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author achepta
  7. // @include /^https{0,1}:\/\/((www|qrator)(\.heroeswm\.ru|\.lordswm\.com)|178\.248\.235\.15)\/.+/
  8. // @grant unsafeWindow
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_log
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function (window, undefined) {
  15. let w;
  16. if (typeof unsafeWindow !== undefined) {
  17. w = unsafeWindow;
  18. } else {
  19. w = window;
  20. }
  21. if (w.self !== w.top) {
  22. return;
  23. }
  24. if (/cgame/.test(location.href)) {
  25. return
  26. }
  27. let allTexts = getAllTexts()
  28. let defaultSettings = getDefaultSettings()
  29.  
  30. let language = /lordswm/.test(location.href) ? "eng" : "rus"
  31. let settings = {}
  32. let headerInfo = {}
  33. let timersInfo = {}
  34.  
  35. loadSettings();
  36. loadTimersInfo();
  37.  
  38. if (settings['isDarkTheme'] && !/war\.php/.test(location.href)) {
  39. applyDarkTheme()
  40. }
  41. document.addEventListener("DOMContentLoaded", () => {
  42. if (!/war\.php/.test(location.href)) {
  43. processPage()
  44. addStyle();
  45. getHeaderInfo()
  46. drawNewHeader()
  47. processSettings();
  48. addMenu();
  49. } else {
  50. processBattle()
  51. }
  52. });
  53.  
  54.  
  55. function addStyle() {
  56. document.body.insertAdjacentHTML("beforeend", getStyles())
  57. }
  58.  
  59. function addMenu() {
  60. $('hwm_header_settings_button').addEventListener('click', handleOnSettingsButtonClick);
  61. }
  62.  
  63.  
  64. // logic
  65. function processSettings() {
  66. if (settings.isTimeWithSeconds) {
  67. showTimeWithSeconds()
  68. }
  69. if (settings.isShowTimers) {
  70. showTimers()
  71. }
  72. }
  73.  
  74. function getHeaderInfo() {
  75. headerInfo['logo'] = getHeaderLogo()
  76. headerInfo['notifications'] = getHeaderNotifications()
  77. headerInfo['homeColor'] = getHomeButtonColor()
  78. headerInfo['battleColor'] = getBattleButtonColor()
  79. headerInfo['resources'] = getHeaderResources()
  80. headerInfo['online'] = getHwmOnline()
  81. }
  82.  
  83. function getHeaderLogo() {
  84. return document.querySelector("div.sh_logo > img").src
  85. }
  86.  
  87. function getHeaderNotifications() {
  88. return Array.from(document.getElementsByClassName("NotificationIcon"))
  89. }
  90.  
  91. function getHomeButtonColor() {
  92. return document.querySelector("#MenuHome").offsetParent.classList.value.split("_").slice(-1)[0]
  93. }
  94.  
  95. function getBattleButtonColor() {
  96. return document.querySelector("#MenuBattles").offsetParent.classList.value.split("_").slice(-1)[0]
  97. }
  98.  
  99. function getHeaderResources() {
  100. let resources = {}
  101. let resourceDivs = document.querySelectorAll("div.sh_ResourcesItem")
  102. Array.from(resourceDivs).forEach(item => {
  103. let resName = getResNameFromImage(item.firstChild.src)
  104. resources[resName] = item.lastChild.textContent
  105. })
  106. return resources
  107. }
  108.  
  109. function getResNameFromImage(src) {
  110. return src.match(/(\w+)\.png/)[1]
  111. }
  112.  
  113. function getHwmOnline() {
  114. return document.querySelector("div.sh_extra.sh_extra_right > div.mm_extra_separator").nextElementSibling.textContent
  115. }
  116.  
  117. function drawNewHeader() {
  118. removeElement($('hwm_header'))
  119. document.body.insertAdjacentHTML('afterbegin', getNewHeaderTemplate())
  120. unsafeWindow.top_line_draw_canvas_heart(100, 100, 900)
  121. unsafeWindow.top_line_add_events_listeners()
  122. }
  123.  
  124. function showTimeWithSeconds() {
  125. let hwmDate = hwmDateToHuman(getHwmDate());
  126. let timePlace = $('hwm_time');
  127. timePlace.innerHTML = hwmDate
  128. setTimeout(showTimeWithSeconds, 1000)
  129. }
  130.  
  131. function showTimers() {
  132. $('timers_container').innerHTML = getTimersTemplate()
  133. setTimeout(showTimers, 1000)
  134. }
  135.  
  136. function applyDarkTheme() {
  137. document.head.insertAdjacentHTML("beforeend", getDarkStyles())
  138.  
  139. }
  140.  
  141. function showEmptyBackground() {
  142. document.body.insertAdjacentHTML('beforeend', getEmptyBackgroundTemplate());
  143. $('empty_background').addEventListener('click', handleOnBackgroundClick);
  144. }
  145.  
  146. function hideEmptyBackground() {
  147. removeElement($('empty_background'))
  148. }
  149.  
  150. function showSettings() {
  151. document.body.insertAdjacentHTML('beforeend', getSettingsTemplate())
  152. fillSettings()
  153. }
  154.  
  155. function fillSettings() {
  156. let settingsField = $('hwm_header_settings');
  157. for (const [key, value] of Object.entries(settings)) {
  158. settingsField.insertAdjacentHTML("beforeend",
  159. `<div id="${key}">
  160. <input id="${key}_checkbox" type="checkbox" ${value ? ' checked' : ''}>
  161. <label for="${key}_checkbox">${getTranslation(key)}</label>
  162. </div>
  163. `)
  164. $(`${key}`).addEventListener('click', () => {
  165. handleSettingsChange(key)
  166. })
  167. }
  168. }
  169.  
  170. function hideSettings() {
  171. removeElement($('hwm_header_settings'))
  172. }
  173.  
  174. function processButtonDropDown(buttonInfo) {
  175. if (buttonInfo.id === "MenuInventory" || buttonInfo.id === "MenuTavern") {
  176. return
  177. }
  178. let target = $(buttonInfo.id+"_expandable")
  179. if (buttonInfo.id === "MenuBattles") {
  180. Array.from(target.getElementsByTagName('a')).slice(8).forEach(item => {
  181. buttonInfo.dropDown.push([item.textContent, item.href, true])
  182. })
  183. }
  184. target.innerHTML = ''
  185. buttonInfo.dropDown.forEach(item => {
  186. if (item.length > 2) {
  187. target.insertAdjacentHTML('beforeend', `<a href="${item[1]}" style="text-decoration:none;"><div class="sh_dd_container_red">${item[0]}</div></a>`)
  188. } else {
  189. target.insertAdjacentHTML('beforeend', `<a href="${item[1]}" style="text-decoration:none;"><div>${getTranslation(item[0])}</div></a>`)
  190. }
  191. })
  192. target.insertAdjacentHTML("beforeend", `<img src="https://dcdn.heroeswm.ru/i/new_top/mm_dd_decorM.png" class="mm_decor2">`)
  193. target.insertAdjacentHTML("beforeend", `<img src="https://dcdn.heroeswm.ru/i/new_top/mm_dd_decorT.png" class="mm_decor3">`)
  194. }
  195.  
  196. function processPage() {
  197. if (/home/.test(location.href)) {
  198. let isPremium = document.body.innerHTML.match(/star.gif/)
  199. timersInfo.isPremium = !!isPremium
  200. }
  201. if (/object_do/.test(location.href)) {
  202. if (document.body.textContent.match(/(successfully|устроены)/)) {
  203. timersInfo.labor_guild_timer_data = getHwmDate()
  204. }
  205. }
  206. let battleId = new URLSearchParams(new URL(document.referrer).search).get("warid")
  207. if (timersInfo.leader_guild_timer_data && !timersInfo.leader_guild_timer_data.timeSet && battleId === timersInfo.leader_guild_timer_data.battleId) {
  208. timersInfo.leader_guild_timer_data.timeSet = getHwmDate()
  209. } else if (timersInfo.thief_guild_timer_data && !timersInfo.thief_guild_timer_data.timeSet && battleId === timersInfo.thief_guild_timer_data.battleId) {
  210. timersInfo.thief_guild_timer_data.timeSet = getHwmDate()
  211. } else if (timersInfo.hunt_guild_timer_data && !timersInfo.hunt_guild_timer_data.timeSet && battleId === timersInfo.hunt_guild_timer_data.battleId) {
  212. timersInfo.hunt_guild_timer_data.timeSet = getHwmDate()
  213. }
  214. set("timers_data", timersInfo)
  215. }
  216.  
  217. function processBattle() {
  218. let battleData = unsafeWindow.run_all.toString()
  219. let battleType = battleData.match(/btype\|(\d{1,10})/)[1]
  220. let battlePlayer = battleData.match(/plid1\|(\d{1,10})/)[1]
  221. let battleId = new URLSearchParams(window.location.search).get("warid")
  222. if (battlePlayer === getCookie("pl_id")) {
  223. if (battleType === "127") {
  224. if ("leader_guild_timer_data" in timersInfo) {
  225. if (timersInfo.leader_guild_timer_data.battleId < battleId) {
  226. timersInfo.leader_guild_timer_data = {"battleId": battleId}
  227. }
  228. } else {
  229. timersInfo.leader_guild_timer_data = {"battleId": battleId}
  230. }
  231. } else if (battleType === "66") {
  232. if ("thief_guild_timer_data" in timersInfo) {
  233. if (timersInfo.thief_guild_timer_data.battleId < battleId) {
  234. timersInfo.thief_guild_timer_data = {"battleId": battleId}
  235. }
  236. } else {
  237. timersInfo.thief_guild_timer_data = {"battleId": battleId}
  238. }
  239. } else if (battleType === "0") {
  240. if ("hunt_guild_timer_data" in timersInfo) {
  241. if (timersInfo.hunt_guild_timer_data.battleId < battleId) {
  242. timersInfo.hunt_guild_timer_data = {"battleId": battleId}
  243. }
  244. } else {
  245. timersInfo.hunt_guild_timer_data = {"battleId": battleId}
  246. }
  247. }
  248. set("timers_data", timersInfo)
  249. }
  250. }
  251.  
  252. // listeners
  253. function handleOnSettingsButtonClick() {
  254. showEmptyBackground();
  255. showSettings();
  256. }
  257.  
  258. function handleOnBackgroundClick() {
  259. hideEmptyBackground();
  260. hideSettings();
  261. }
  262.  
  263. function handleSettingsChange(key) {
  264. settings[key] = $(`${key}_checkbox`).checked
  265. set('hwm_header_settings', settings)
  266. }
  267.  
  268. // templates
  269. function getSettingsButtonTemplate() {
  270. return `
  271. <img
  272. id="hwm_header_settings_button"
  273. src="https://dcdn3.heroeswm.ru/i/combat/btn_settings.png?v=8"
  274. height="18"
  275. alt="Header settings"
  276. style="position: relative; filter: drop-shadow(0.01rem 0.01rem 0 black) drop-shadow(-0.01rem -0.01rem 0 black); transform: rotate(22.5deg)"
  277. title="Header settings"
  278. >`
  279. }
  280.  
  281. function getEmptyBackgroundTemplate() {
  282. return `
  283. <div id="empty_background" style="
  284. position: absolute;
  285. left: 0;
  286. top: 0;
  287. width: 100%;
  288. height: ${getScrollHeight()};
  289. background: #000000;
  290. opacity: 0.5;
  291. z-index: 1100;
  292. "></div>
  293. `
  294. }
  295.  
  296. function getSettingsTemplate() {
  297. return `
  298. <div id="hwm_header_settings" style="
  299. position: absolute;
  300. left: ${(getClientWidth() - 600) / 2}px;
  301. top: ${window.pageYOffset + 155}px;
  302. width: 600px;
  303. background: #F6F3EA;
  304. z-index: 1101;
  305. ">
  306. </div>
  307. `
  308. }
  309.  
  310. function getNewHeaderTemplate() {
  311. return `
  312. <div id="new_header">
  313. <div class="top_line">
  314. <div class="top_left_container">
  315. <!-- <div class="top_left_left">-->
  316. <!-- </div>-->
  317. <div class="top_wing_middle">
  318. <div id="notifications">
  319. ${getNotificationsTemplate()}
  320. </div>
  321. </div>
  322. <div class="top_left_right">
  323. <div id="heart_container">
  324. <div class="sh_HMResIconBlock">
  325. <canvas width="64px" height="64px" id="heart"></canvas>
  326. </div>
  327. <div style="display: none;" id="health_amount">100</div>
  328. </div>
  329. </div>
  330. </div>
  331. <div class="top_resource_container" id="top_resource_container">
  332. <div id="ResourcesPanel" class="sh_ResourcesPanel">
  333. ${getResourcesTemplate()}
  334. </div>
  335. </div>
  336. <div class="top_right_container">
  337. <div class="top_right_left">
  338. <div id="mana_container">
  339. <div class="sh_HMResIconBlock mana"></div>
  340. <div class="mana_animation"></div>
  341. <div style="display: none" id="mana_amount">50</div>
  342. </div>
  343. </div>
  344. <div class="top_wing_middle">
  345. <div class="time_online_radio_container">
  346. <div id="hwm_time"></div>
  347. <div class="mm_extra_separator"></div>
  348. <div id="hwm_online">${headerInfo['online']} online</div>
  349. <div class="mm_extra_separator"></div>
  350. <div class="mm_extra_radio" onclick="hwm_top_line_open_radio(620, 400);return false;"></div>
  351. <div class="mm_extra_separator"></div>
  352. <div id="">${getSettingsButtonTemplate()}</div>
  353. </div>
  354. </div>
  355. <!-- <div class="top_right_right">-->
  356.  
  357. <!-- </div>-->
  358. </div>
  359. </div>
  360. <div class="new_header_menu">
  361. <!-- <img src="https://dcdn.heroeswm.ru/i/new_top/mm_decor1.png" class="mm_decor1">-->
  362. <div class="left_dragon">
  363. <img height="70px" src="https://i.pinimg.com/originals/6c/2e/0b/6c2e0be6ebdad0e7f4bc86bc1f10e451.png">
  364. </div>
  365. <div class="middle_menus">
  366. <div class="timers_container" id="timers_container"></div>
  367. <div class="common_menu_container">
  368. ${getMenuButtonsTemplate()}
  369. </div>
  370. </div>
  371. <div class="right_dragon">
  372. <img height="70px" src="https://i.imgur.com/oqyVp7G.png">
  373. </div>
  374. </div>
  375. </div>
  376. `
  377. }
  378.  
  379. function getNotificationsTemplate() {
  380. return headerInfo['notifications'].reduce((result, current) => {
  381. // #говнокод
  382. if (current.src.includes("pismo")) {
  383. return result + `<a href="sms.php">${current.outerHTML.toString()}</a>`;
  384. } else {
  385. return result + current.outerHTML.toString()
  386. }}, "")
  387. }
  388.  
  389. function getResourcesTemplate() {
  390. let newResources = []
  391. let resourceLinks = getResourceLinks()
  392. for (const [key, value] of Object.entries(headerInfo['resources'])) {
  393. let template = `
  394. <div class="sh_ResourcesItem">
  395. <a href="${resourceLinks[key]}">
  396. <img class="sh_ResourcesItem_icon" src="https://dcdn.heroeswm.ru/i/r/48/${key}.png?v=3.23de65" alt="${key}" title="${key}">
  397. </a>
  398. <span class="select_auto_enabled">${value}</span></div>
  399. `
  400. newResources.push(template)
  401. }
  402. return newResources.join(`<div class="mm_rp_separator"></div>`)
  403. }
  404.  
  405. function getMenuButtonsTemplate() {
  406. let buttonsToShow = getAvailableButtons()
  407. return buttonsToShow.reduce((result, current) => result + getMenuButtonHTML(current), "")
  408. }
  409.  
  410. function getAvailableButtons() {
  411. let buttons = []
  412. for (const [key, value] of Object.entries(getButtonInfos())) {
  413. if (settings[key]) {
  414. buttons.push(value)
  415. }
  416. }
  417. return buttons
  418. }
  419.  
  420. function getMenuButtonHTML(buttonInfo) {
  421. processButtonDropDown(buttonInfo)
  422. let buttonInside = ``
  423. if (settings['isTextButtons']) {
  424. buttonInside = `<div class="menu_button_text">${getTranslation(buttonInfo.id)}</div>`
  425. } else {
  426. buttonInside = `<img class="mm_item_icon" src="${buttonInfo.image}">`
  427. }
  428. let buttonColor = ``
  429. if (headerInfo['homeColor'] === 'red') {
  430. buttonColor = 'red'
  431. } else if (headerInfo['battleColor'] === 'orange' && buttonInfo.id === "MenuBattles") {
  432. buttonColor = 'orange'
  433. } else if (headerInfo['battleColor'] === 'red' && buttonInfo.id === "MenuBattles") {
  434. buttonColor = 'red'
  435. } else {
  436. buttonColor = 'blue'
  437. }
  438. return `
  439. <div class="mm_item mm_item_${buttonColor}">
  440. <a href="${buttonInfo.href}">
  441. <div class="mm_item_inside" id="${buttonInfo.id}" hwm_label="">
  442. ${buttonInside}
  443. </div>
  444. </a>
  445. </div>
  446. `
  447. }
  448.  
  449. function getTimersTemplate() {
  450. let isPremium = timersInfo.isPremium ? timersInfo.isPremium : false
  451. let result = ''
  452. if (timersInfo.labor_guild_timer_data) {
  453. let timeCount = isPremium ? 60 : 60
  454. result += `
  455. <div class="mm_item mm_item_blue">
  456. <div class="menu_button_text">${getTranslation("labor_guild")} ${getRemainingTime(timersInfo.labor_guild_timer_data, timeCount)}</div>
  457. </div>`
  458. } else {
  459. result += `
  460. <div class="mm_item mm_item_blue">
  461. <div class="menu_button_text">${getTranslation("labor_guild")} 00:00</div>
  462. </div>`
  463. }
  464. if (timersInfo.hunt_guild_timer_data && timersInfo.hunt_guild_timer_data.timeSet) {
  465. let timeCount = isPremium ? 28 : 40
  466. result += `
  467. <div class="mm_item mm_item_blue">
  468. <div class="menu_button_text">${getTranslation("hunt_guild")} ${getRemainingTime(timersInfo.hunt_guild_timer_data.timeSet, timeCount)}</div>
  469. </div>`
  470. } else {
  471. result += `
  472. <div class="mm_item mm_item_blue">
  473. <div class="menu_button_text">${getTranslation("hunt_guild")} 00:00</div>
  474. </div>`
  475. }
  476. if (timersInfo.thief_guild_timer_data && timersInfo.thief_guild_timer_data.timeSet) {
  477. let timeCount = isPremium ? 42 : 60
  478. result += `
  479. <div class="mm_item mm_item_blue">
  480. <div class="menu_button_text">${getTranslation("thief_guild")} ${getRemainingTime(timersInfo.thief_guild_timer_data.timeSet, timeCount)}</div>
  481. </div>`
  482. } else {
  483. result += `
  484. <div class="mm_item mm_item_blue">
  485. <div class="menu_button_text">${getTranslation("thief_guild")} 00:00</div>
  486. </div>`
  487. }
  488. if (timersInfo.leader_guild_timer_data && timersInfo.leader_guild_timer_data.timeSet) {
  489. let timeCount = isPremium ? 180 : 180
  490. result += `
  491. <div class="mm_item mm_item_blue">
  492. <div class="menu_button_text">${getTranslation("leader_guild")} ${getRemainingTime(timersInfo.leader_guild_timer_data.timeSet, timeCount)}</div>
  493. </div>`
  494. } else {
  495. result += `
  496. <div class="mm_item mm_item_blue">
  497. <div class="menu_button_text">${getTranslation("leader_guild")} 00:00</div>
  498. </div>`
  499. }
  500. return result
  501. }
  502. function getRemainingTime(timeSet, timeCount) {
  503. let hwmDate = getHwmDate()
  504. let timeSetHwm = new Date(timeSet)
  505. return secondsToHumanDate(diffDateInSeconds(timeSetHwm, hwmDate) + timeCount * 60)
  506. }
  507. function diffDateInSeconds(dt1, dt2) {
  508. return Math.round((dt1.getTime() - dt2.getTime()) / 1000);
  509. }
  510. // helpers
  511. function getCookie(name) {
  512. const value = `; ${document.cookie}`;
  513. const parts = value.split(`; ${name}=`);
  514. if (parts.length === 2) return parts.pop().split(';').shift();
  515. }
  516.  
  517. function doGet(url, callback) {
  518. GM_xmlhttpRequest({
  519. method: "GET",
  520. url: url,
  521. overrideMimeType: "text/xml; charset=windows-1251",
  522. onload: function (res) {
  523. callback(new DOMParser().parseFromString(res.responseText, "text/html"))
  524. }
  525. });
  526. }
  527.  
  528. function doPost(url, params, callback) {
  529. GM_xmlhttpRequest({
  530. method: "POST",
  531. url: url,
  532. data: params,
  533. onload: callback,
  534. });
  535. }
  536.  
  537. function removeElement(element) {
  538. element.parentNode.removeChild(element)
  539. }
  540.  
  541. function $(id, where = document) {
  542. return where.querySelector(`#${id}`);
  543. }
  544.  
  545. function get(key, def) {
  546. let result = JSON.parse(localStorage[key] === undefined ? null : localStorage[key]);
  547. return result == null ? def : result;
  548.  
  549. }
  550.  
  551. function set(key, val) {
  552. localStorage[key] = JSON.stringify(val);
  553. }
  554.  
  555. function getScrollHeight() {
  556. return Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
  557. }
  558.  
  559. function getClientWidth() {
  560. return document.compatMode === 'CSS1Compat' && document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
  561. }
  562.  
  563. function findAll(regexPattern, sourceString) {
  564. let output = []
  565. let match
  566. let regexPatternWithGlobal = RegExp(regexPattern, [...new Set("g" + regexPattern.flags)].join(""))
  567. while (match = regexPatternWithGlobal.exec(sourceString)) {
  568. delete match.input
  569. output.push(match)
  570. }
  571. return output
  572. }
  573.  
  574. function sortByKey(array, key) {
  575. return array.sort((a, b) => {
  576. let x = a[key];
  577. let y = b[key];
  578. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  579. });
  580. }
  581.  
  582. function getHwmDate() {
  583. let today = new Date();
  584. let localOffset = -(today.getTimezoneOffset() / 60);
  585. let destinationOffset = +3;
  586.  
  587. let offset = destinationOffset - localOffset;
  588. return new Date(new Date().getTime() + offset * 3600 * 1000)
  589.  
  590. }
  591.  
  592. function hwmDateToHuman(hwmDate) {
  593. let hours = hwmDate.getHours().toString().length === 1
  594. ? "0" + hwmDate.getHours().toString()
  595. : hwmDate.getHours().toString()
  596. let minutes = hwmDate.getMinutes().toString().length === 1
  597. ? "0" + hwmDate.getMinutes().toString()
  598. : hwmDate.getMinutes().toString()
  599. let seconds = hwmDate.getSeconds().toString().length === 1
  600. ? "0" + hwmDate.getSeconds().toString()
  601. : hwmDate.getSeconds().toString()
  602. return hours + ":" + minutes + ":" + seconds
  603. }
  604.  
  605. function secondsToHumanDate(seconds) {
  606. // Hours, minutes and seconds
  607. var hrs = ~~(seconds / 3600);
  608. var mins = ~~((seconds % 3600) / 60);
  609. var secs = ~~seconds % 60;
  610.  
  611. // Output like "1:01" or "4:03:59" or "123:03:59"
  612. var ret = "";
  613. if (hrs > 0) {
  614. ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
  615. }
  616. ret += "" + mins + ":" + (secs < 10 ? "0" : "");
  617. ret += "" + secs;
  618. return ret;
  619. }
  620.  
  621. function getTranslation(textId) {
  622. return allTexts[textId][language]
  623. }
  624.  
  625. function loadSettings() {
  626. settings = get('hwm_header_settings', defaultSettings)
  627. for (const [key, value] of Object.entries(defaultSettings)) {
  628. if (settings[key] === undefined) {
  629. settings[key] = value
  630. }
  631. }
  632. }
  633.  
  634. function loadTimersInfo() {
  635. timersInfo = get('timers_data', {})
  636. }
  637. function getAllTexts() {
  638. return {
  639. 'isTimeWithSeconds': {
  640. "rus": "Показывать время с секундами",
  641. "eng": "Show time with seconds",
  642. },
  643. 'isShowTimers': {
  644. "rus": "Показывать таймеры гильдий",
  645. "eng": "Show guilds' timers",
  646. },
  647. 'isDarkTheme': {
  648. "rus": "Темная тема",
  649. "eng": "Dark theme"
  650. },
  651. 'isTextButtons': {
  652. "rus": "Старые текстовые кнопки",
  653. "eng": "Show old text buttons"
  654. },
  655. 'isHomeButton': {
  656. "rus": "Персонаж",
  657. "eng": "Home"
  658. },
  659. 'isInventoryButton': {
  660. "rus": "Инвентарь",
  661. "eng": "Inventory"
  662. },
  663. 'isMapButton': {
  664. "rus": "Карта",
  665. "eng": "Map"
  666. },
  667. 'isBattleButton': {
  668. "rus": "Битвы",
  669. "eng": "Battles"
  670. },
  671. 'isTavernButton': {
  672. "rus": "Таверна",
  673. "eng": "Tavern"
  674. },
  675. 'isRouletteButton': {
  676. "rus": "Рулетка",
  677. "eng": "Roulette"
  678. },
  679. 'isLeaderboardButton': {
  680. "rus": "Рейтинг",
  681. "eng": "Leaderboards"
  682. },
  683. 'isForumButton': {
  684. "rus": "Форум",
  685. "eng": "Forum"
  686. },
  687. 'isChatButton': {
  688. "rus": "Чат",
  689. "eng": "Chat"
  690. },
  691. 'MenuHome': {
  692. "rus": "Персонаж",
  693. "eng": "Home"
  694. },
  695. 'MenuInventory': {
  696. "rus": "Инвентарь",
  697. "eng": "Inventory"
  698. },
  699. 'MenuMap': {
  700. "rus": "Карта",
  701. "eng": "Map"
  702. },
  703. 'MenuBattles': {
  704. "rus": "Битвы",
  705. "eng": "Battles"
  706. },
  707. 'MenuTavern': {
  708. "rus": "Таверна",
  709. "eng": "Tavern"
  710. },
  711. 'MenuRoulette': {
  712. "rus": "Рулетка",
  713. "eng": "Roulette"
  714. },
  715. 'MenuStat': {
  716. "rus": "Рейтинг",
  717. "eng": "Leaderboards"
  718. },
  719. 'MenuForum': {
  720. "rus": "Форум",
  721. "eng": "Forum"
  722. },
  723. 'MenuChat': {
  724. "rus": "Чат",
  725. "eng": "Chat"
  726. },
  727. 'myself': {
  728. "rus": "Я",
  729. "eng": "Myself"
  730. },
  731. 'inventory': {
  732. "rus": "Инвентарь",
  733. "eng": "Inventory"
  734. },
  735. 'shop': {
  736. "rus": "Магазин",
  737. "eng": "Artifact shop"
  738. },
  739. 'auction': {
  740. "rus": "Рынок",
  741. "eng": "Market"
  742. },
  743. 'choose_army': {
  744. "rus": "Набор армии",
  745. "eng": "Recruiting"
  746. },
  747. 'castle': {
  748. "rus": "Замок",
  749. "eng": "Castle"
  750. },
  751. 'skills': {
  752. "rus": "Навыки",
  753. "eng": "Talents"
  754. },
  755. 'mailbox': {
  756. "rus": "Почта",
  757. "eng": "Mailbox"
  758. },
  759. 'transfer': {
  760. "rus": "Передача ресурсов",
  761. "eng": "Transfer"
  762. },
  763. 'facility1': {
  764. "rus": "Добыча",
  765. "eng": "Mining"
  766. },
  767. 'facility2': {
  768. "rus": "Обработка",
  769. "eng": "Machining"
  770. },
  771. 'facility3': {
  772. "rus": "Производство",
  773. "eng": "Production"
  774. },
  775. 'houses': {
  776. "rus": "Дома",
  777. "eng": "Public services"
  778. },
  779. 'one_to_one': {
  780. "rus": "Дуэли",
  781. "eng": "Duels"
  782. },
  783. 'many_to_many': {
  784. "rus": "Групповые бои",
  785. "eng": "Group battles"
  786. },
  787. 'guild_pvp': {
  788. "rus": "Гильдия тактиков",
  789. "eng": "Commanders' guild"
  790. },
  791. 'guild_task': {
  792. "rus": "Гильдия стражей",
  793. "eng": "Watchers' guild"
  794. },
  795. 'guild_leader': {
  796. "rus": "Гильдия лидеров",
  797. "eng": "Leaders guild"
  798. },
  799. 'clanwars': {
  800. "rus": "Бои за территории",
  801. "eng": "Clan wars"
  802. },
  803. 'tournaments': {
  804. "rus": "Турниры",
  805. "eng": "Tounaments"
  806. },
  807. 'spin_history': {
  808. "rus": "История игр",
  809. "eng": "Spin history"
  810. },
  811. 'lucky_boxes': {
  812. "rus": "Редкие ларцы",
  813. "eng": "Chests of abundance"
  814. },
  815. 'top_heroes': {
  816. "rus": "Рейтинг воинов",
  817. "eng": "Top warriors"
  818. },
  819. 'top_clans': {
  820. "rus": "Рейтинг кланов",
  821. "eng": "Top clans"
  822. },
  823. 'top_hunters': {
  824. "rus": "Рейтинг охотников",
  825. "eng": "Top hunters"
  826. },
  827. 'top_mercenaries': {
  828. "rus": "Рейтинг наемников",
  829. "eng": "Top mercenaries"
  830. },
  831. 'top_shareholders': {
  832. "rus": "Рейтинг акционеров",
  833. "eng": "Top shareholders"
  834. },
  835. 'personal_records': {
  836. "rus": "Мои охоты",
  837. "eng": "My hunt records"
  838. },
  839. 'general_forum': {
  840. "rus": "Общий форум",
  841. "eng": "General forum"
  842. },
  843. 'help_forum': {
  844. "rus": "Помощь по игре",
  845. "eng": "Q&A forum"
  846. },
  847. 'trade_forum': {
  848. "rus": "Торговый форум",
  849. "eng": "Trade forums"
  850. },
  851. 'reference': {
  852. "rus": "Об игре",
  853. "eng": "About the game"
  854. },
  855. 'hwm_newspaper': {
  856. "rus": "Новостная лента",
  857. "eng": "Daily news"
  858. },
  859. 'chat_1': {
  860. "rus": "Комната вопросов",
  861. "eng": "Inquiry"
  862. },
  863. 'chat_2': {
  864. "rus": "Общая комната",
  865. "eng": "Common"
  866. },
  867. 'chat_3': {
  868. "rus": "Торговая палата",
  869. "eng": "Merchant"
  870. },
  871. 'chat_4': {
  872. "rus": "Рулетка",
  873. "eng": "Roulette"
  874. },
  875. 'chat_5': {
  876. "rus": "Карты",
  877. "eng": "Tavern"
  878. },
  879. 'labor_guild': {
  880. "rus": "ГР",
  881. "eng": "LG"
  882. },
  883. 'leader_guild': {
  884. "rus": "ГЛ",
  885. "eng": "LeG"
  886. },
  887. 'hunt_guild': {
  888. "rus": "ГО",
  889. "eng": "HG"
  890. },
  891. 'thief_guild': {
  892. "rus": "ГВ",
  893. "eng": "TG"
  894. },
  895. '': {
  896. "rus": "",
  897. "eng": ""
  898. },
  899.  
  900. }
  901. }
  902.  
  903. function getDefaultSettings() {
  904. return {
  905. "isTimeWithSeconds": true,
  906. "isShowTimers": true,
  907. "isDarkTheme": true,
  908. "isTextButtons": false,
  909. "isHomeButton": true,
  910. "isInventoryButton": false,
  911. "isMapButton": true,
  912. "isBattleButton": true,
  913. "isTavernButton": true,
  914. "isRouletteButton": true,
  915. "isLeaderboardButton": true,
  916. "isForumButton": true,
  917. "isChatButton": true,
  918. }
  919. }
  920.  
  921. function getButtonInfos() {
  922. return {
  923. "isHomeButton": {
  924. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelCharacter.png",
  925. "id": "MenuHome",
  926. "href": "home.php",
  927. "dropDown": [
  928. ["myself", `pl_info.php?id=${getCookie("pl_id")}`],
  929. ["inventory", "inventory.php"],
  930. ["shop", "shop.php"],
  931. ["auction", "auction.php"],
  932. ["choose_army", "army.php"],
  933. ["castle", "castle.php"],
  934. ["skills", "skillwheel.php"],
  935. ["mailbox", "sms.php"],
  936. ["transfer", "transfer.php"],
  937. ]
  938. },
  939. "isInventoryButton": {
  940. "image": "https://dcdn.heroeswm.ru/i/mobile_view/icons/_panelInventory.png",
  941. "id": "MenuInventory",
  942. "href": "inventory.php",
  943. "dropDown": []
  944. },
  945. "isMapButton": {
  946. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelMap.png",
  947. "id": "MenuMap",
  948. "href": "map.php",
  949. "dropDown": [
  950. ["facility1", "map.php?st=mn"],
  951. ["facility2", "map.php?st=fc"],
  952. ["facility3", "map.php?st=sh"],
  953. ["houses", "map.php?st=hs"],
  954. ]
  955. },
  956. "isBattleButton": {
  957. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelBattles.png",
  958. "id": "MenuBattles",
  959. "href": "bselect.php",
  960. "dropDown": [
  961. ["one_to_one", "one_to_one.php"],
  962. ["many_to_many", "group_wars.php"],
  963. ["guild_pvp", "pvp_guild.php"],
  964. ["guild_task", "task_guild.php"],
  965. ["guild_leader", "leader_guild.php"],
  966. ["clanwars", "mapwars.php"],
  967. ["tournaments", "tournaments.php"],
  968. ]
  969. },
  970. "isTavernButton": {
  971. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelTavern.png",
  972. "id": "MenuTavern",
  973. "href": "tavern.php",
  974. "dropDown": []
  975. },
  976. "isRouletteButton": {
  977. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelRoulette.png",
  978. "id": "MenuRoulette",
  979. "href": "roulette.php",
  980. "dropDown": [
  981. ["spin_history", "allroul.php"],
  982. ["lucky_boxes", "gift_box_log.php"],
  983.  
  984. ]
  985. },
  986. "isLeaderboardButton": {
  987. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelRate.png",
  988. "id": "MenuStat",
  989. "href": "plstats.php",
  990. "dropDown": [
  991. ["top_heroes", "plstats.php"],
  992. ["top_clans", "clanstat.php"],
  993. ["top_hunters", "plstats_hunters.php"],
  994. ["top_mercenaries", "plstats_merc.php"],
  995. ["top_shareholders", "sholders_stat.php"],
  996. ["personal_records", `pl_hunter_stat.php?id=${getCookie("pl_id")}`],
  997.  
  998. ]
  999. },
  1000. "isForumButton": {
  1001. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelForum.png",
  1002. "id": "MenuForum",
  1003. "href": "forum.php",
  1004. "dropDown": [
  1005. ["general_forum", "forum_thread.php?id=2"],
  1006. ["help_forum", "forum_thread.php?id=10"],
  1007. ["trade_forum", "forum.php#t1"],
  1008. ["reference", "help.php"],
  1009. ["hwm_newspaper", "https://daily.heroeswm.ru/"],
  1010.  
  1011. ]
  1012. },
  1013. "isChatButton": {
  1014. "image": "https://dcdn.heroeswm.ru/i/new_top/_panelChat.png",
  1015. "id": "MenuChat",
  1016. "href": "frames.php",
  1017. "dropDown": [
  1018. ["chat_1", "frames.php?room=0"],
  1019. ["chat_2", "frames.php?room=1"],
  1020. ["chat_3", "frames.php?room=2"],
  1021. ["chat_4", "frames.php?room=3"],
  1022. ["chat_5", "frames.php?room=4"],
  1023. ]
  1024. },
  1025. }
  1026. }
  1027.  
  1028. function getResourceLinks() {
  1029. return {
  1030. "gold": "roulette.php",
  1031. "wood": "auction.php?cat=res&sort=0&type=1",
  1032. "ore": "auction.php?cat=res&sort=0&type=2",
  1033. "mercury": "auction.php?cat=res&sort=0&type=3",
  1034. "sulfur": "auction.php?cat=res&sort=0&type=4",
  1035. "crystals": "auction.php?cat=res&sort=0&type=5",
  1036. "gems": "auction.php?cat=res&sort=0&type=6",
  1037. "diamonds": "hwm_donate_page_new.php",
  1038. }
  1039. }
  1040.  
  1041. function getStyles() {
  1042. return `
  1043. <style>
  1044. ${settings.isTextButtons ? ".mm_item, .mm_item_inside {height:24px}; .mm_item_inside {display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center;} .menu_button_text{height:100%}" : ""};
  1045. body {
  1046. margin: 0;
  1047. padding: 0;
  1048. }
  1049.  
  1050. #new_header {
  1051. display: flex;
  1052. flex-direction: column;
  1053. align-items: center;
  1054. }
  1055.  
  1056. .top_line {
  1057. width: 100%;
  1058. height: 32px;
  1059. display: flex;
  1060. flex-direction: row;
  1061. flex-wrap: nowrap;
  1062. }
  1063.  
  1064. .top_left_container, .top_right_container {
  1065. height: 100%;
  1066. display: flex;
  1067. flex-direction: row;
  1068. flex-wrap: nowrap;
  1069. flex-grow: 1;
  1070. }
  1071.  
  1072. .top_left_left {
  1073. height: 100%;
  1074. width: 52px;
  1075. background-image: url("https://dcdn.heroeswm.ru/i/new_top/extra_bg_side2.png");
  1076. background-size: 256px 32px;
  1077. background-repeat: no-repeat;
  1078. }
  1079.  
  1080. .top_left_right {
  1081. min-width: 100px;
  1082. background: url("https://dcdn.heroeswm.ru/i/new_top/extra_bg_side1.png") no-repeat top right;
  1083. background-size: 256px 32px;
  1084.  
  1085. }
  1086.  
  1087. /*#logo_container {*/
  1088. /* position: relative;*/
  1089. /*}*/
  1090. /*.logo {*/
  1091. /* max-width: 128px;*/
  1092. /* max-height: 64px;*/
  1093. /*}*/
  1094. #notifications {
  1095. height: 32px;
  1096. float: right;
  1097. display: flex;
  1098. flex-direction: row;
  1099. flex-wrap: nowrap;
  1100. align-items: center;
  1101. margin-right: 10%;
  1102. }
  1103.  
  1104. #heart_container {
  1105. background-image: url("https://dcdn.heroeswm.ru/i/new_top/mm_rp_health.png");
  1106. background-size: contain;
  1107. width: 32px;
  1108. height: 32px;
  1109. margin: auto;
  1110. }
  1111.  
  1112. #heart_container:hover #health_amount {
  1113. display: initial !important;
  1114. position: absolute;
  1115. color: white;
  1116. transform: translate(10%, -100%);
  1117. text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000;
  1118.  
  1119. }
  1120.  
  1121. .sh_HMResIconBlock {
  1122. position: relative;
  1123. left: 15px;
  1124. top: 15px;
  1125. }
  1126.  
  1127. .health_animation {
  1128. position: relative;
  1129. }
  1130.  
  1131. #heart {
  1132. width: 27px;
  1133. height: 27px;
  1134. }
  1135.  
  1136. #mana_container {
  1137. background-image: url("https://dcdn.heroeswm.ru/i/new_top/mm_rp_mana.png");
  1138. background-size: contain;
  1139. width: 32px;
  1140. height: 32px;
  1141. margin: auto;
  1142. display: grid;
  1143. grid-template-columns: 1fr;
  1144. grid-template-rows: 1fr;
  1145. overflow: hidden;
  1146. }
  1147. .mana_animation {
  1148. position: relative;
  1149. grid-column-start: 1;
  1150. grid-row-start: 1;
  1151. z-index: 4;
  1152. }
  1153.  
  1154. .mana {
  1155. grid-column-start: 1;
  1156. grid-row-start: 1;
  1157. z-index: 3;
  1158. }
  1159.  
  1160. #mana_amount {
  1161. grid-column-start: 1;
  1162. grid-row-start: 1;
  1163. z-index: 5;
  1164. margin: auto;
  1165. color: white;
  1166. }
  1167.  
  1168. #mana_container:hover #mana_amount {
  1169. display: initial !important;
  1170. color: white;
  1171. text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000;
  1172. }
  1173.  
  1174. .top_right_right {
  1175. width: 52px;
  1176. background: url("https://dcdn.heroeswm.ru/i/new_top/extra_bg_side2.png") no-repeat top right;
  1177. background-size: 256px 32px;
  1178. }
  1179.  
  1180. .top_right_left {
  1181. min-width: 100px;
  1182. background: url("https://dcdn.heroeswm.ru/i/new_top/extra_bg_side1.png") no-repeat top left;
  1183. background-size: 256px 32px;
  1184. }
  1185.  
  1186. .top_wing_middle {
  1187. min-width: 175px;
  1188. width: 100%;
  1189. background: url("https://dcdn.heroeswm.ru/i/new_top/extra_bg_mid.png") repeat-x top left;
  1190. background-size: 32px;
  1191. }
  1192.  
  1193. .time_online_radio_container {
  1194. display: flex;
  1195. flex-direction: row;
  1196. flex-wrap: nowrap;
  1197. align-items: center;
  1198. margin-left: 10%;
  1199. }
  1200. #hwm_time, #hwm_online {
  1201. color: #b12424;
  1202. }
  1203.  
  1204. .top_resource_container {
  1205. background: url("https://dcdn.heroeswm.ru/i/new_top/rp_bg_mid.png");
  1206. background-size: contain;
  1207. }
  1208.  
  1209. .new_header_menu {
  1210. background: url("https://dcdn.heroeswm.ru/i/new_top/mm_dd_tile.jpg");
  1211. min-height: 70px;
  1212. padding: 0;
  1213. width: 100%;
  1214. display: flex;
  1215. flex-direction: row;
  1216. flex-wrap: nowrap;
  1217. justify-content: space-between;
  1218. }
  1219. .common_menu_container {
  1220. margin-top: 5px;
  1221. display: flex;
  1222. flex-direction: row;
  1223. flex-wrap: nowrap;
  1224. justify-content: center;
  1225. align-items: center;
  1226. overflow: hidden;
  1227. }
  1228. .timers_container {
  1229. display: flex;
  1230. flex-direction: row;
  1231. flex-wrap: nowrap;
  1232. justify-content: center;
  1233. align-items: center;
  1234. overflow: hidden;
  1235. }
  1236. .mm_item {
  1237. margin: 0;
  1238. }
  1239. .mm_item + .mm_item {
  1240. margin-left: 5px;
  1241. }
  1242.  
  1243. .left_dragon, .right_dragon {
  1244. }
  1245. .left_dragon {
  1246. transform: scaleX(-1);
  1247. }
  1248. .middle_menus {
  1249. display: flex;
  1250. flex-direction: column;
  1251. justify-content: center;
  1252. }
  1253. .menu_button_text {
  1254. display: flex;
  1255. justify-content: center;
  1256. align-items: center;
  1257. color: #fad49f;
  1258. font-weight: bold;
  1259. }
  1260. </style>
  1261. `
  1262. }
  1263.  
  1264. function getDarkStyles() {
  1265. let mainTextColor = `#d0d0d0`
  1266. return `
  1267. <style>
  1268. body {
  1269. background: #1f2023 !important;
  1270. }
  1271. td, .forum > td {
  1272. color: ${mainTextColor} !important;
  1273. background-image: none !important;
  1274. }
  1275. font {
  1276. color: ${mainTextColor} !important;
  1277. opacity: 0.65;
  1278. }
  1279. a, .forum > a {
  1280. color: ${mainTextColor} !important;
  1281. /*opacity: 0.87;*/
  1282. }
  1283. div {
  1284. color: #121212;
  1285. }
  1286. .txt {
  1287. color: ${mainTextColor};
  1288. /*opacity: 0.87;*/
  1289. }
  1290. .pi {
  1291. color: ${mainTextColor};
  1292. /*opacity: 0.87;*/
  1293. }
  1294. .wblight, .wb2, .wb td{
  1295. background-color: #2d2f34;
  1296. }
  1297. .wbwhite {
  1298. background-color: #383b40;
  1299. }
  1300. table.table3, table.table3 th {
  1301. background-color: #383b40;
  1302. }
  1303. .forum tr:not(.second) > td {
  1304. background-color: #383b40 !important;
  1305. }
  1306. table.forum tr.message_footer td {
  1307. background-color: #27292d !important;
  1308. }
  1309. .forum span, .second {
  1310. background-color: #2d2f34 !important;
  1311. }
  1312. #home_2 {
  1313. color: ${mainTextColor};
  1314. }
  1315. #hwm_for_zoom {
  1316. background-color: #27292d !important;
  1317. }
  1318. #hwm_for_zoom * {
  1319. color: ${mainTextColor};
  1320. }
  1321. .dark_seconds {
  1322. color: #a50909;
  1323. }
  1324. * {
  1325. border-color: #55565d !important;
  1326. }
  1327. table td.tlight {
  1328. background-color: #2d2f34 !important;
  1329. background-image: none;
  1330. }
  1331. table td.twhite {
  1332. background-color: #383b40 !important;
  1333. background-image: none;
  1334. }
  1335. #pa,#pd, #pp, #pk, #pl, #pm, #pi, #ap, #sc {
  1336. color: ${mainTextColor} !important;
  1337. }
  1338. </style>
  1339. `
  1340. }
  1341. })(window);