IdlePixel UI Tweaks (Lite)

Adds some options to change details about the IdlePixel user interface.

  1. // ==UserScript==
  2. // @name IdlePixel UI Tweaks (Lite)
  3. // @namespace luxferre.dev
  4. // @version 0.9.1
  5. // @description Adds some options to change details about the IdlePixel user interface.
  6. // @author Lux-Ferre
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play/
  9. // @grant none
  10. // @require https://gf.qytechs.cn/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20250125
  11. // @require https://gf.qytechs.cn/scripts/491983-idlepixel-plugin-paneller/code/IdlePixel%2B%20Plugin%20Paneller.js?anticache=20250129
  12. // ==/UserScript==
  13.  
  14. // Original Author: Anwinity || Original fork by: GodofNades || Rewritten with ♡ by: Lux-ferre
  15.  
  16. (function () {
  17. "use strict";
  18.  
  19. class UITweaksPlugin extends IdlePixelPlusPlugin {
  20. constructor() {
  21. super("ui-tweaks-lite", {
  22. about: {
  23. name: GM_info.script.name + " (ver: " + GM_info.script.version + ")",
  24. version: GM_info.script.version,
  25. author: GM_info.script.author,
  26. description: GM_info.script.description,
  27. },
  28. })
  29. this.loaded = false
  30.  
  31. this.get_selectors()
  32. this.get_default_colours()
  33. this.get_default_settings()
  34. this.load_settings()
  35. this.generate_user_stylesheet()
  36. this.modify_dom()
  37. this.replace_yell_method()
  38.  
  39. this.smelt_times = {
  40. copper: 3 - 1,
  41. iron: 6 - 1,
  42. silver: 10 - 1,
  43. gold: 50 - 1,
  44. promethium: 100 - 1,
  45. titanium: 500 - 1,
  46. ancient_ore: 1800 - 1,
  47. dragon_ore: 3600 - 1,
  48. }
  49. this.smelt_timer = null;
  50. }
  51.  
  52. create_settings_modal() {
  53. const modal_string = `<div class="modal fade" id="uit_settings" tabindex="-1" data-bs-theme="dark">
  54. <div class="modal-dialog" style="max-width: 50vw; max-height: 75vh; transform: translate(-20%)">
  55. <div class="modal-content" style="height: 75vh;">
  56. <ul class="nav nav-tabs" id="controlPanelTabs">
  57. <li class="nav-item">
  58. <button class="uit_tab_button nav-link active" id="toggles-tab" data-bs-toggle="tab" data-bs-target="#toggles" type="button">
  59. <i class="fas fa-toggle-on me-2"></i>Toggles
  60. </button>
  61. </li>
  62. <li class="nav-item">
  63. <button class="uit_tab_button nav-link" id="misc-settings-tab" data-bs-toggle="tab" data-bs-target="#misc_settings" type="button">
  64. <i class="fas fa-list-check me-2"></i>Misc
  65. </button>
  66. </li>
  67. <li class="nav-item">
  68. <button class="uit_tab_button nav-link" id="bg-colours-tab" data-bs-toggle="tab" data-bs-target="#bg_colours" type="button">
  69. <i class="fas fa-palette me-2"></i>Background Colours
  70. </button>
  71. </li>
  72. <li class="nav-item">
  73. <button class="uit_tab_button nav-link" id="text-colors-tab" data-bs-toggle="tab" data-bs-target="#text_colours" type="button">
  74. <i class="fas fa-font me-2"></i>Text Colours
  75. </button>
  76. </li>
  77. </ul>
  78. <div class="px-3">
  79. <div class="tab-content mt-3" id="controlPanelTabContent">
  80. <div class="tab-pane fade show active" id="toggles">
  81. <div class="row g-4 d-flex justify-content-around text-center">
  82. <!-- Toggles will be dynamically inserted here -->
  83. </div>
  84. </div>
  85. <div class="tab-pane fade" id="misc_settings">
  86. <div class="row g-4 d-flex justify-content-around text-center">
  87. <!-- Settings will be dynamically inserted here -->
  88. </div>
  89. </div>
  90. <div class="tab-pane fade" id="bg_colours">
  91. <div class="row g-4 d-flex justify-content-around text-center">
  92. <!-- Color pickers will be dynamically inserted here -->
  93. </div>
  94. </div>
  95. <div class="tab-pane fade" id="text_colours">
  96. <div class="row g-4 d-flex justify-content-around text-center">
  97. <!-- Color pickers will be dynamically inserted here -->
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>`
  105. document.body.insertAdjacentHTML("beforeend", modal_string);
  106. }
  107.  
  108. populate_settings() {
  109. this.ps_background_colours()
  110. this.ps_text_colours()
  111. this.ps_toggles()
  112. this.ps_misc()
  113. }
  114.  
  115. ps_background_colours() {
  116. function rgb_to_hex(rgb) {
  117. const [r, g, b] = rgb.match(/\d+/g).map(Number);
  118. return `#${((1 << 24) | (r << 16) | (g << 8) | b).toString(16).slice(1)}`;
  119. }
  120.  
  121. function create_colour_picker(colour, self) {
  122. let colour_value = self.settings.get(colour.id) || "rgb(0, 0, 0)"
  123. if (colour_value.startsWith('rgb')) {
  124. colour_value = rgb_to_hex(colour_value)
  125. }
  126.  
  127. return `
  128. <div class="col d-flex align-items-center justify-content-center p-1" style="min-width: 250px; max-width: 250px; border: 2px outset gray">
  129. <input type="color" class="color-picker form-control me-1" id="uitl_${colour.id}" data-ident="${colour.id}" value="${colour_value}">
  130. <label for="uitl_${colour.id}" class="form-label m-0">${colour.label}</label>
  131. </div>
  132. `
  133. }
  134.  
  135. const bg_colours = [
  136. {id: "main_background", label: "Main Background"},
  137. {id: "panel_background", label: "Panel Background"},
  138. {id: "top_bar_background", label: "Top Bar Background"},
  139. {id: "upper_stats_bar_background", label: "Upper Stats Bar Background"},
  140. {id: "lower_stats_bar_background", label: "Lower Top Bar Background"},
  141. {id: "left_bar_background", label: "Left Bar Background"},
  142. {id: "chat_inner_background", label: "Chat Inner Background"},
  143. {id: "chat_outer_background", label: "Chat Outer Background"},
  144. {id: "chat_border", label: "Chat Border"},
  145. {id: "server_message_tag", label: "Server Message Tag"},
  146. {id: "chat_raid_link_background", label: "Chat Raid Link Background"},
  147. ]
  148.  
  149. const background_container = document.querySelector('#bg_colours .row')
  150. background_container.innerHTML = ""
  151.  
  152. bg_colours.forEach(colour => {
  153. background_container.innerHTML += create_colour_picker(colour, this);
  154. })
  155.  
  156. background_container.querySelectorAll("input").forEach(input => {
  157. const self = IdlePixelPlus.plugins["ui-tweaks-lite"]
  158. input.addEventListener("input", (e) => {
  159. const ident = e.target.dataset.ident
  160. const prop = ident === "chat_border" ? "border-color" : "background-color"
  161. self.update_css(self.selector_map[ident], prop, e.target.value)
  162. self.update_setting(ident, e.target.value)
  163. })
  164. })
  165. }
  166.  
  167. ps_text_colours() {
  168. function rgb_to_hex(rgb) {
  169. const [r, g, b] = rgb.match(/\d+/g).map(Number);
  170. return `#${((1 << 24) | (r << 16) | (g << 8) | b).toString(16).slice(1)}`;
  171. }
  172.  
  173. function create_colour_picker(colour, self) {
  174. let colour_value = self.settings.get(colour.id) || "rgb(0, 0, 0)"
  175. if (colour_value.startsWith('rgb')) {
  176. colour_value = rgb_to_hex(colour_value)
  177. }
  178.  
  179. return `
  180. <div class="col d-flex align-items-center justify-content-center p-1" style="min-width: 250px; max-width: 250px; border: 2px outset gray">
  181. <input type="color" class="color-picker form-control me-1" id="uitl_${colour.id}" data-ident="${colour.id}" value="${colour_value}">
  182. <label for="uitl_${colour.id}" class="form-label m-0">${colour.label}</label>
  183. </div>
  184. `
  185. }
  186.  
  187. const text_colours = [
  188. {id: "chat_text", label: "Chat Text"},
  189. {id: "chat_timestamp_text", label: "Chat Timestamp Text"},
  190. {id: "chat_username_text", label: "Chat Username Text"},
  191. {id: "chat_level_text", label: "Chat Level Text"},
  192. {id: "server_message_text", label: "Server Message Text"},
  193. {id: "server_message_tag_text", label: "Server Message Tag Text"},
  194. {id: "chat_raid_link_text", label: "Chat Raid Link Text"},
  195. {id: "panel_text_1", label: "Panel Text 1"},
  196. {id: "panel_text_2", label: "Panel Text 2"},
  197. {id: "skill_level_text", label: "Skill Level Text"}
  198. ]
  199.  
  200. const text_container = document.querySelector('#text_colours .row');
  201. text_container.innerHTML = ""
  202.  
  203. text_colours.forEach(colour => {
  204. text_container.innerHTML += create_colour_picker(colour, this);
  205. })
  206.  
  207. text_container.querySelectorAll("input").forEach(input => {
  208. const self = IdlePixelPlus.plugins["ui-tweaks-lite"]
  209. input.addEventListener("input", (e) => {
  210. const ident = e.target.dataset.ident
  211. const prop = "color"
  212. self.update_css(self.selector_map[ident], prop, e.target.value)
  213. self.update_setting(ident, e.target.value)
  214. })
  215. })
  216. }
  217.  
  218. ps_toggles() {
  219. function createToggle(toggle) {
  220. return `
  221. <div class="col d-flex align-items-center justify-content-center p-1" style="min-width: 250px; max-width: 250px; border: 2px inset gray">
  222. <div class="form-check form-switch">
  223. <input class="form-check-input me-1" type="checkbox" id="uitl_${toggle.id}">
  224. <label class="form-check-label" for="uitl_${toggle.id}">${toggle.label}</label>
  225. </div>
  226. </div>
  227. `
  228. }
  229.  
  230. const toggles = [];
  231. const toggles_container = document.querySelector('#toggles .row');
  232. toggles_container.innerHTML = ""
  233.  
  234. toggles.forEach(toggle => {
  235. toggles_container.innerHTML += createToggle(toggle);
  236. })
  237. }
  238.  
  239. ps_misc() {
  240. const misc_container = document.querySelector('#misc_settings .row');
  241. misc_container.innerHTML = ""
  242.  
  243. let user_font = this.settings.get("font") || "IdlePixel Default"
  244.  
  245. misc_container.innerHTML += `
  246. <div class="col d-flex align-items-center justify-content-center p-1" style="min-width: 250px; max-width: 250px; border: 2px outset gray">
  247. <label for="font_picker" class="form-label m-0 me-2">Font</label>
  248. <select class="form-select font_picker" id="font_picker"></select>
  249. </div>
  250. `
  251. this.font_list.forEach(font => {
  252. const selected_attr = font === user_font ? "selected" : ""
  253. const option_str = `<option ${selected_attr} value="${font}">${font}</option>`
  254. document.getElementById("font_picker").innerHTML += option_str
  255. })
  256.  
  257. document.getElementById("font_picker").addEventListener("change", function (event) {
  258. const self = IdlePixelPlus.plugins["ui-tweaks-lite"]
  259. user_font = event.target.value
  260. if (user_font === "IdlePixel Default") {
  261. user_font = self.default_settings["font"]
  262. }
  263. self.update_css("body.font-famlies", "font-family", user_font)
  264. self.update_css("#chat-area", "font-family", user_font)
  265. self.update_setting("font", user_font)
  266. });
  267. }
  268.  
  269. show_modal() {
  270. IdlePixelPlus.plugins["ui-tweaks-lite"].populate_settings()
  271. $("#uit_settings").modal("show")
  272. }
  273.  
  274. get_default_colours() {
  275. $("#chat-area").append($.parseHTML(`<div id="temp_chat_colour_picker"><div class="chat-username"></div><div class="server_message"></div><div class="server_message_text"></div></div>`))
  276. this.default_colours = {
  277. main_background: "rgb(200, 247, 248)",
  278. panel_background: getComputedStyle(document.querySelector("#panels")).backgroundColor,
  279. top_bar_background: getComputedStyle(document.querySelector(".game-top-bar")).backgroundColor,
  280. upper_stats_bar_background: getComputedStyle(document.querySelector(".game-top-bar-lower")).backgroundColor,
  281. lower_stats_bar_background: getComputedStyle(document.querySelector(".game-top-bar-optional-lower")).backgroundColor,
  282. left_bar_background: getComputedStyle(document.querySelector("#menu-bar")).backgroundColor,
  283. chat_inner_background: getComputedStyle(document.querySelector("#chat-area")).backgroundColor,
  284. chat_outer_background: getComputedStyle(document.querySelector("#game-chat")).backgroundColor,
  285. chat_border: getComputedStyle(document.querySelector("#game-chat.chat.m-3")).borderColor,
  286. server_message_tag: getComputedStyle(document.querySelector(".server_message")).backgroundColor,
  287. server_message_tag_text: getComputedStyle(document.querySelector(".server_message")).color,
  288. chat_text: getComputedStyle(document.querySelector("#chat-area")).color,
  289. chat_timestamp_text: "rgb(0, 128, 0)",
  290. chat_username_text: getComputedStyle(document.querySelector(".chat-username")).color,
  291. chat_level_text: "rgb(128, 128, 128)",
  292. server_message_text: getComputedStyle(document.querySelector(".server_message")).color,
  293. chat_raid_link_text: "rgb(197 186 186)",
  294. chat_raid_link_background: "rgb(139, 0, 0)",
  295. panel_text_1: getComputedStyle(document.querySelector("#panels")).color,
  296. panel_text_2: "rgb(128, 128, 128)",
  297. skill_level_text: getComputedStyle(document.querySelector("#panels .font-large")).color,
  298. }
  299. const ele = document.getElementById("temp_chat_colour_picker")
  300. if (ele) {
  301. ele.remove()
  302. }
  303. }
  304.  
  305. get_font_list() {
  306. const possible_fonts = new Set(
  307. [
  308. // Windows 10
  309. "Arial",
  310. "Arial Black",
  311. "Bahnschrift",
  312. "Calibri",
  313. "Cambria",
  314. "Cambria Math",
  315. "Candara",
  316. "Comic Sans MS",
  317. "Consolas",
  318. "Constantia",
  319. "Corbel",
  320. "Courier New",
  321. "Ebrima",
  322. "Franklin Gothic Medium",
  323. "Gabriola",
  324. "Gadugi",
  325. "Georgia",
  326. "HoloLens MDL2 Assets",
  327. "Impact",
  328. "Ink Free",
  329. "Javanese Text",
  330. "Leelawadee UI",
  331. "Lucida Console",
  332. "Lucida Sans Unicode",
  333. "Malgun Gothic",
  334. "Marlett",
  335. "Microsoft Himalaya",
  336. "Microsoft JhengHei",
  337. "Microsoft New Tai Lue",
  338. "Microsoft PhagsPa",
  339. "Microsoft Sans Serif",
  340. "Microsoft Tai Le",
  341. "Microsoft YaHei",
  342. "Microsoft Yi Baiti",
  343. "MingLiU-ExtB",
  344. "Mongolian Baiti",
  345. "MS Gothic",
  346. "MV Boli",
  347. "Myanmar Text",
  348. "Nirmala UI",
  349. "Palatino Linotype",
  350. "Segoe MDL2 Assets",
  351. "Segoe Print",
  352. "Segoe Script",
  353. "Segoe UI",
  354. "Segoe UI Historic",
  355. "Segoe UI Emoji",
  356. "Segoe UI Symbol",
  357. "SimSun",
  358. "Sitka",
  359. "Sylfaen",
  360. "Symbol",
  361. "Tahoma",
  362. "Times New Roman",
  363. "Trebuchet MS",
  364. "Verdana",
  365. "Webdings",
  366. "Wingdings",
  367. "Yu Gothic",
  368. // macOS
  369. "American Typewriter",
  370. "Andale Mono",
  371. "Arial",
  372. "Arial Black",
  373. "Arial Narrow",
  374. "Arial Rounded MT Bold",
  375. "Arial Unicode MS",
  376. "Avenir",
  377. "Avenir Next",
  378. "Avenir Next Condensed",
  379. "Baskerville",
  380. "Big Caslon",
  381. "Bodoni 72",
  382. "Bodoni 72 Oldstyle",
  383. "Bodoni 72 Smallcaps",
  384. "Bradley Hand",
  385. "Brush Script MT",
  386. "Chalkboard",
  387. "Chalkboard SE",
  388. "Chalkduster",
  389. "Charter",
  390. "Cochin",
  391. "Comic Sans MS",
  392. "Copperplate",
  393. "Courier",
  394. "Courier New",
  395. "Didot",
  396. "DIN Alternate",
  397. "DIN Condensed",
  398. "Futura",
  399. "Geneva",
  400. "Georgia",
  401. "Gill Sans",
  402. "Helvetica",
  403. "Helvetica Neue",
  404. "Herculanum",
  405. "Hoefler Text",
  406. "Impact",
  407. "Lucida Grande",
  408. "Luminari",
  409. "Marker Felt",
  410. "Menlo",
  411. "Microsoft Sans Serif",
  412. "Monaco",
  413. "Noteworthy",
  414. "Optima",
  415. "Palatino",
  416. "Papyrus",
  417. "Phosphate",
  418. "Rockwell",
  419. "Savoye LET",
  420. "SignPainter",
  421. "Skia",
  422. "Snell Roundhand",
  423. "Tahoma",
  424. "Times",
  425. "Times New Roman",
  426. "Trattatello",
  427. "Trebuchet MS",
  428. "Verdana",
  429. "Zapfino",
  430. // other
  431. "Helvetica",
  432. "Garamond",
  433. ].sort()
  434. )
  435.  
  436. this.font_list = []
  437.  
  438. for (const font of possible_fonts.values()) {
  439. if (document.fonts.check(`12px "${font}"`)) {
  440. this.font_list.push(font);
  441. }
  442. }
  443. this.font_list.unshift("IdlePixel Default")
  444. }
  445.  
  446. get_default_settings() {
  447. this.default_settings = {
  448. font: getComputedStyle(document.querySelector("body")).fontFamily,
  449. good_moon: 300000,
  450. good_sun: 120000000
  451. }
  452. }
  453.  
  454. get_selectors() {
  455. this.selector_map = {
  456. main_background: ".background-game",
  457. panel_background: "#panels",
  458. top_bar_background: ".game-top-bar",
  459. upper_stats_bar_background: ".game-top-bar-lower",
  460. lower_stats_bar_background: ".game-top-bar-optional-lower",
  461. left_bar_background: "#menu-bar",
  462. chat_inner_background: "#chat-area",
  463. chat_outer_background: "#game-chat",
  464. chat_border: "#game-chat",
  465. server_message_tag: ".server_message",
  466. server_message_tag_text: ".server_message",
  467. chat_text: "#chat-area",
  468. chat_timestamp_text: "#chat-area .color-green",
  469. chat_username_text: ".chat-username",
  470. chat_level_text: "#chat-area .color-grey",
  471. server_message_text: ".server_message_text",
  472. chat_raid_link_text: ".raid-link",
  473. chat_raid_link_background: ".raid-link",
  474. panel_text_1: "#panels",
  475. panel_text_2: "#panels .color-grey",
  476. skill_level_text: "#panels .font-large"
  477. }
  478.  
  479. }
  480.  
  481. load_settings() {
  482. this.settings = new Map([
  483. ...Object.entries(this.default_colours),
  484. ...Object.entries(this.default_settings),
  485. ])
  486. const stored_settings = localStorage.getItem("uit-lite-settings")
  487. if (stored_settings) {
  488. const parsed_settings = JSON.parse(stored_settings)
  489. this.settings.forEach((value, key) => {
  490. if (parsed_settings.hasOwnProperty(key)) {
  491. this.settings.set(key, parsed_settings[key])
  492. } else {
  493. console.log("Unknown setting key: " + key)
  494. }
  495. })
  496. console.log("Lite settings loaded.")
  497. } else {
  498. const uit_configs = JSON.parse(localStorage.getItem("idlepixelplus.ui-tweaks.config"))
  499. if (uit_configs) {
  500. console.log("Legacy UIT settings loaded.")
  501. try {
  502. this.get_uit_configs()
  503. } catch (e) {
  504. console.error(`Error loading UIT configs: ${e}`)
  505. }
  506. } else {
  507. console.log("Only default settings loaded.")
  508. }
  509. }
  510. this.save_settings()
  511. }
  512.  
  513. save_settings() {
  514. const json_settings = JSON.stringify(Object.fromEntries(this.settings))
  515. localStorage.setItem("uit-lite-settings", json_settings)
  516. }
  517.  
  518. get_uit_configs() {
  519. const uit_configs = JSON.parse(localStorage.getItem("idlepixelplus.ui-tweaks.config"))
  520. this.settings
  521. .set("main_background", uit_configs["color-body"] || this.default_colours.main_background)
  522. .set("panel_background", uit_configs["color-panels"] || this.default_colours.panel_background)
  523. .set("top_bar_background", uit_configs["color-top-bar"] || this.default_colours.top_bar_background)
  524. .set("left_bar_background", uit_configs["color-menu-bar"] || this.default_colours.left_bar_background)
  525. .set("chat_inner_background", uit_configs["color-chat-area"] || this.default_colours.chat_inner_background)
  526. .set("chat_outer_background", uit_configs["color-game-chat"] || this.default_colours.chat_outer_background)
  527. .set("chat_border", uit_configs["chatBorderOverrideColor"] || this.default_colours.chat_border)
  528. .set("server_message_tag", uit_configs["color-chat-area-server_message"] || this.default_colours.server_message_tag)
  529. .set("server_message_tag_text", uit_configs["serverMessageTextOverrideColor"] || this.default_colours.server_message_tag_text)
  530. .set("chat_text", uit_configs["font-color-chat-area"] || this.default_colours.chat_text)
  531. .set("chat_timestamp_text", uit_configs["font-color-chat-area-color-green"] || this.default_colours.chat_timestamp_text)
  532. .set("chat_username_text", uit_configs["font-color-chat-area-chat-username"] || this.default_colours.chat_username_text)
  533. .set("chat_level_text", uit_configs["font-color-chat-area-color-grey"] || this.default_colours.chat_level_text)
  534. .set("server_message_text", uit_configs["serverMessageTextOverrideColor"] || this.default_colours.server_message_text)
  535. .set("chat_raid_link_text", uit_configs["font-color-chat-area-chat-raid-password"] || this.default_colours.chat_raid_link_text)
  536. .set("chat_raid_link_background", uit_configs["background-color-chat-area-raid-password"] || this.default_colours.chat_raid_link_background)
  537. .set("panel_text_1", uit_configs["font-color-panels"] || this.default_colours.panel_text_1)
  538. .set("panel_text_2", uit_configs["font-color-panels-color-grey"] || this.default_colours.panel_text_2)
  539. .set("skill_level_text", uit_configs["font-color-panels-font-large"] || this.default_colours.skill_level_text)
  540. .set("font", uit_configs["font"] || this.default_settings.font)
  541. }
  542.  
  543. apply_set_styles() {
  544. const style = document.createElement("style")
  545. style.id = "uit-lite-set-styles"
  546. style.textContent = `
  547. #content.side-chat #game-chat > :first-child {
  548. display: grid;
  549. column-gap: 0;
  550. row-gap: 0;
  551. grid-template-columns: 1fr;
  552. grid-template-rows: auto 1fr auto;
  553. height: calc(100% - 16px);
  554. }
  555. .farming-plot-wrapper.condensed {
  556. min-width: 115px;
  557. display: flex;
  558. flex-direction: row;
  559. justify-items: flex-start;
  560. width: fit-content;
  561. height: unset;
  562. min-height: unset;
  563. max-height: unset;
  564. }
  565. .farming-plot-wrapper.condensed > span {
  566. width: 100px;
  567. max-height: 200px;
  568. }
  569. .farming-plot-wrapper.condensed img {
  570. width: 100px;
  571. }
  572. #panel-gathering .gathering-box.condensed {
  573. height: 240px;
  574. position: relative;
  575. margin: 4px auto;
  576. padding-left: 4px;
  577. padding-right: 4px;
  578. }
  579. #panel-gathering .gathering-box.condensed img.gathering-area-image {
  580. position: absolute;
  581. top: 10px;
  582. left: 10px;
  583. width: 68px;
  584. height: 68px;
  585. }
  586. #panel-mining.add-arrow-controls itembox {
  587. position: relative;
  588. }
  589. #panel-mining:not(.add-arrow-controls) itembox .arrow-controls {
  590. display: none !important;
  591. }
  592. itembox .arrow-controls {
  593. position: absolute;
  594. top: 0px;
  595. right: 2px;
  596. height: 100%;
  597. padding: 2px;
  598. display: flex;
  599. flex-direction: column;
  600. justify-content: space-around;
  601. align-items: center;
  602. }
  603. itembox .arrow {
  604. border: solid white;
  605. border-width: 0 4px 4px 0;
  606. display: inline-block;
  607. padding: 6px;
  608. cursor: pointer;
  609. opacity: 0.85;
  610. }
  611. itembox .arrow:hover {
  612. opacity: 1;
  613. border-color: yellow;
  614. }
  615. itembox .arrow.up {
  616. transform: rotate(-135deg);
  617. -webkit-transform: rotate(-135deg);
  618. margin-top: 3px;
  619. }
  620. itembox .arrow.down {
  621. transform: rotate(45deg);
  622. -webkit-transform: rotate(45deg);
  623. margin-bottom: 3px;
  624. }
  625.  
  626. .itembox-large {
  627. width: 204px;
  628. margin-bottom: 15px;
  629. }
  630. .game-menu-bar-left-table-btn tr
  631. {
  632. background-color: transparent !important;
  633. font-size:medium;
  634. }
  635. .hover-menu-bar-item:hover {
  636. background: unset;
  637. font-size: medium;
  638. }
  639. .thin-progress-bar {
  640. background:#437b7c !important;
  641. border:0 !important;
  642. height:unset;
  643. }
  644. .thin-progress-bar-inner {
  645. background:#88e8ea !important;
  646. }
  647. .game-menu-bar-left-table-btn td{
  648. padding-left:20px !important;
  649. padding:unset;
  650. margin:0px;
  651. font-size:medium;
  652. }
  653.  
  654. .game-menu-bar-left-table-btn div td{
  655. padding-left:20px !important;
  656. padding:unset;
  657. margin:0px;
  658. font-size:medium;
  659. background-color: transparent !important;
  660. }
  661.  
  662. .game-menu-bar-left-table-btn {
  663. background-color: transparent !important;
  664. }
  665. .left-menu-item {
  666. margin-bottom:unset;
  667. font-size:medium;
  668. }
  669. .left-menu-item > img {
  670. margin-left: 20px;
  671. margin-right: 20px;
  672. }
  673. .color-picker {
  674. width: 40px;
  675. height: 40px;
  676. padding: 0;
  677. border: solid 2px black;
  678. border-radius: 50%;
  679. cursor: pointer;
  680. }
  681. .color-picker::-webkit-color-swatch-wrapper {
  682. padding: 0;
  683. }
  684. .color-picker::-webkit-color-swatch {
  685. border: none;
  686. border-radius: 4px;
  687. }
  688. .uit_tab_button {
  689. border: none;
  690. box-shadow: none;
  691. border-radius: none;
  692. }
  693. #uit_settings .active {
  694. background-color:inherit !important;
  695. color:white !important;
  696. }
  697. .left_menu_divider {
  698. border-bottom: lightgray 1px outset;
  699. }
  700. #notifications-area {
  701. overflow-y: auto;
  702. height: 140px;
  703. }
  704. .uit_hidden {
  705. display: none;
  706. }
  707. `
  708.  
  709. document.head.appendChild(style)
  710. }
  711.  
  712. generate_user_stylesheet() {
  713. const style = document.createElement("style")
  714. style.id = "uit-lite-user-styles"
  715. style.textContent = `
  716. body.font-famlies {
  717. font-family: ${this.settings.get("font")};
  718. }
  719. .background-game {
  720. background-color: ${this.settings.get("main_background")};
  721. }
  722. #panels {
  723. background-color: ${this.settings.get("panel_background")};
  724. color: ${this.settings.get("panel_text_1")};
  725. }
  726. .game-top-bar {
  727. background-color: ${this.settings.get("top_bar_background")};
  728. }
  729. .game-top-bar-lower {
  730. background-color: ${this.settings.get("upper_stats_bar_background")};
  731. }
  732. .game-top-bar-optional-lower {
  733. background-color: ${this.settings.get("lower_stats_bar_background")};
  734. }
  735. #menu-bar {
  736. background-color: ${this.settings.get("left_bar_background")};
  737. }
  738. #chat-area {
  739. background-color: ${this.settings.get("chat_inner_background")};
  740. color: ${this.settings.get("chat_text")};
  741. font-family: ${this.settings.get("font")};
  742. }
  743. #game-chat {
  744. background-color: ${this.settings.get("chat_outer_background")};
  745. border-color: ${this.settings.get("chat_border")};
  746. }
  747. .server_message {
  748. background-color: ${this.settings.get("server_message_tag")};
  749. color: ${this.settings.get("server_message_tag_text")};
  750. }
  751. .server_message_text {
  752. color: ${this.settings.get("server_message_text")};
  753. }
  754. #chat-area .color-green {
  755. color: ${this.settings.get("chat_timestamp_text")};
  756. }
  757. .chat-username {
  758. color: ${this.settings.get("chat_username_text")};
  759. }
  760. #chat-area .color-grey {
  761. color: ${this.settings.get("chat_level_text")};
  762. }
  763. .raid-link {
  764. background-color: ${this.settings.get("chat_raid_link_background")};
  765. color: ${this.settings.get("chat_raid_link_text")};
  766. }
  767. #panels .color-grey {
  768. color: ${this.settings.get("panel_text_2")};
  769. }
  770. #panels .font-large {
  771. color: ${this.settings.get("skill_level_text")};
  772. }
  773. .sun_distance{}
  774. .moon_distance{}
  775. `
  776.  
  777. document.head.appendChild(style)
  778. }
  779.  
  780. modify_dom() {
  781. // DOM modifications to allow stylesheet rule overrides
  782. // Removes inline styles from levels on skill panels.
  783. document.querySelectorAll("#panels .font-large").forEach(element => {
  784. element.removeAttribute("style")
  785. })
  786.  
  787. const moon_distance = document.getElementById("top-bar-moon-distance")
  788. moon_distance.classList.add("moon_distance")
  789. moon_distance.removeAttribute("style")
  790. document.body.appendChild(document.createElement("div")).id = "top-bar-moon-distance" // Creates a new element to be targeted by colouration code
  791. moon_distance.removeAttribute("id") // Removes ID to prevent future inline styles being applies
  792.  
  793. const sun_distance = document.getElementById("top-bar-sun-distance")
  794. sun_distance.classList.add("sun_distance")
  795. document.body.appendChild(document.createElement("div")).id = "top-bar-sun-distance" // Creates a new element to be targeted by colouration code
  796. sun_distance.removeAttribute("id") // Removes ID to prevent future inline styles being applies
  797. sun_distance.querySelector("item-display").removeAttribute("id") // ID is duplicated to inner element. -.-
  798. }
  799.  
  800. restructure_chat() {
  801. const chat = document.querySelector("#game-chat > :first-child");
  802. const chatTop = document.createElement("div");
  803. chatTop.id = "chat-top";
  804. const chatArea = document.querySelector("#chat-area");
  805. const chatBottom = document.querySelector(
  806. "#game-chat > :first-child > :last-child"
  807. );
  808.  
  809. while (chat.firstChild) {
  810. chatTop.appendChild(chat.firstChild);
  811. }
  812.  
  813. chat.appendChild(chatTop);
  814. chat.appendChild(chatArea);
  815. chat.appendChild(chatBottom);
  816. }
  817.  
  818. show_extended_levels() {
  819. window.refresh_skill_levels_menu_bar = function (skill) {
  820. const level = get_level(Items.getItem(`${skill}_xp`), true);
  821.  
  822. if (level >= 100) {
  823. document.getElementById("menu-bar-" + skill + "-level").innerHTML = `<span style='color:cyan;'>Level 100 (${level})</span>`
  824. } else {
  825. document.getElementById("menu-bar-" + skill + "-level").innerHTML = `Level ${level}`
  826. }
  827. }
  828.  
  829. window.refresh_xp_required_labels = function () {
  830. const skills = ["mining", "crafting", "gathering", "farming", "brewing", "woodcutting", "cooking", "fishing", "breeding", "invention", "melee", "archery", "magic"]
  831. let global_level = 0
  832.  
  833. skills.forEach(skill => {
  834. const current_xp = Items.getItem(skill + "_xp");
  835. const current_level = get_level(current_xp, true);
  836. const xp_required = get_xp_required(current_level + 1);
  837. if (current_level >= 100) hide_element("next-level-" + skill + "-xp-required")
  838. document.getElementById("next-level-" + skill + "-xp-required").innerHTML = format_number(xp_required - current_xp) + " xp until next level";
  839.  
  840. global_level += current_level
  841. })
  842. window.var_global_level_ext = global_level
  843. }
  844.  
  845. const ele = document.createElement("span")
  846. ele.innerHTML = `(<item-display class="font-small" data-key="global_level_ext"></item-display>)`
  847. ele.classList.add("color-silver")
  848. document.querySelector(".game-top-bar-upper > a:nth-child(4) > item-display").insertAdjacentElement("afterend", ele)
  849. }
  850.  
  851. replace_yell_method() {
  852. Chat.yell_to_chat_box = function (data) {
  853. var data_array = data.split("~");
  854. var tag = "Server message";
  855. var tag_css_class = tag.toLowerCase().replaceAll(" ", "_");
  856. var sigil_image = "none";
  857. var usernameSource = data_array[0];
  858. var message = data_array[1];
  859.  
  860. if (Items.getItem("team_chat_on") == 1 && usernameSource != "none") {
  861. var teamUsernames = Items.getItem("team_usernames").split(",");
  862. var found = false;
  863. for (var i = 0; i < teamUsernames.length; i++) {
  864.  
  865. if (teamUsernames[i] == usernameSource) {
  866. found = true;
  867. break;
  868. }
  869. }
  870.  
  871. if (!found)
  872. return;
  873. }
  874.  
  875. var html = "";
  876. html += "<span class='color-green'>" + Chat._get_time() + "</span>";
  877. if (sigil_image != "none") html += " <img src='https://cdn.idle-pixel.com/images/" + sigil_image + ".png' /> ";
  878. if (tag != "none") html += "<span class='" + tag_css_class + " shadow'>" + tag + "</span> ";
  879. html += sanitize_input(message);
  880.  
  881. $("#chat-area").append("<div class='server_message_text'>" + html + "</div>")
  882.  
  883. if (Chat._auto_scroll)
  884. $("#chat-area").scrollTop($("#chat-area")[0].scrollHeight)
  885. };
  886. }
  887.  
  888. move_plugins_button() {
  889. document.getElementById("menu-bar-idlepixelplus-icon")?.parentElement.remove()
  890. Paneller.registerPanel("idlepixelplus", "IP+ Plugin Settings")
  891. }
  892.  
  893. update_css(selector, property, new_value) {
  894. const stylesheet = document.getElementById("uit-lite-user-styles").sheet
  895. const rules = stylesheet.cssRules
  896. for (let i = 0; i < rules.length; i++) {
  897. const rule = rules[i];
  898. if (rule.selectorText === selector) {
  899. rule.style.setProperty(property, new_value);
  900. break;
  901. }
  902. }
  903. }
  904.  
  905. update_setting(setting, value) {
  906. IdlePixelPlus.plugins["ui-tweaks-lite"].settings.set(setting, value);
  907. IdlePixelPlus.plugins["ui-tweaks-lite"].save_settings()
  908. }
  909.  
  910. condense_ui() {
  911. let leftbar = document.getElementById("menu-bar-buttons");
  912.  
  913. let styleElement = document.getElementById("condensed-ui-tweaks");
  914.  
  915. if (styleElement) {
  916. styleElement.parentNode.removeChild(styleElement);
  917. }
  918. document
  919. .getElementById("menu-bar-buttons")
  920. .querySelectorAll(".font-small")
  921. .forEach(function (smallFont) {
  922. let classInfo = smallFont.className.replaceAll(
  923. "font-small",
  924. "font-medium"
  925. );
  926. smallFont.className = classInfo;
  927. })
  928.  
  929. leftbar.querySelectorAll("img").forEach(function (img) {
  930. img.className = "w20";
  931. });
  932. }
  933.  
  934. condense_woodcutting_patches() {
  935. let patch_container = document.createElement("div")
  936. patch_container.classList.add("d-flex")
  937. const woodcutting_plots = document.querySelectorAll("#panel-woodcutting .farming-plot-wrapper")
  938. woodcutting_plots.forEach((plot) => {
  939. plot.classList.add("condensed")
  940. document
  941. .querySelectorAll("#panel-woodcutting .farming-plot-wrapper img[id^='img-tree_shiny']")
  942. .forEach(function (el) {
  943. el.removeAttribute("width");
  944. el.removeAttribute("height");
  945. })
  946. patch_container.appendChild(plot)
  947. })
  948. document.getElementById("panel-woodcutting").appendChild(patch_container)
  949. }
  950.  
  951. condense_farming_patches() {
  952. let patch_container = document.createElement("div")
  953. patch_container.classList.add("d-flex")
  954. const farming_patch_container = document.querySelectorAll("#panel-farming .farming-plot-wrapper")
  955. farming_patch_container.forEach((plot) => {
  956. plot.classList.add("condensed");
  957. document
  958. .querySelectorAll("#panel-farming .farming-plot-wrapper img[id^='img-farm_shiny']")
  959. .forEach(function (el) {
  960. el.removeAttribute("width");
  961. el.removeAttribute("height");
  962. })
  963. patch_container.appendChild(plot)
  964. })
  965. document.getElementById("panel-farming").appendChild(patch_container)
  966. }
  967.  
  968. condense_gathering_boxes() {
  969. const gathering_boxes = document.querySelectorAll("#panel-gathering .gathering-box")
  970. gathering_boxes.forEach(function (box) {
  971. box.classList.add("condensed")
  972. box.querySelector("hr").style.display = "none"
  973. box.querySelectorAll(".color-silver").forEach(element => {
  974. element.style.display = "none"
  975. })
  976. const unique_items = box.querySelector(".color-orange")
  977. unique_items.style.display = ""
  978.  
  979. // Remove new lines after unique items to make progress bar fit.
  980. let next_sibling = unique_items.nextSibling
  981. while (next_sibling) {
  982. if (next_sibling.tagName === "BR") {
  983. const element_to_remove = next_sibling
  984. next_sibling = next_sibling.nextSibling
  985. element_to_remove.remove()
  986. } else {
  987. next_sibling = next_sibling.nextSibling
  988. }
  989. }
  990. })
  991. }
  992.  
  993. give_images_titles() {
  994. const images = document.querySelectorAll("img");
  995. images.forEach(function (el) {
  996. const src = el.getAttribute("src");
  997. if (src && src !== "x") {
  998. const title = src.replace(/.*\//, "").replace(/\.\w+$/, "");
  999. el.setAttribute("title", title);
  1000. }
  1001. })
  1002. }
  1003.  
  1004. add_labels_to_table_items() {
  1005. document.querySelectorAll(`#invention-table tbody tr[data-tablette-required]`).forEach(row => {
  1006. row.querySelectorAll(`td:nth-child(4) item-invention-table`).forEach(output => {
  1007. const label = output.getAttribute("data-materials-item").replaceAll("_", " ")
  1008. output.textContent = `${Number(output.textContent).toLocaleString()} (${label})`
  1009. })
  1010. })
  1011.  
  1012. document.querySelectorAll(`#crafting-table tbody tr[data-crafting-item]`).forEach(row => {
  1013. row.querySelectorAll(`td:nth-child(3) item-crafting-table`).forEach(output => {
  1014. const label = output.getAttribute("data-materials-item").replaceAll("_", " ")
  1015. output.textContent = `${Number(output.textContent).toLocaleString()} (${label})`
  1016. })
  1017. })
  1018.  
  1019. document.querySelectorAll(`#brewing-table tbody tr[data-brewing-item]`).forEach(row => {
  1020. row.querySelectorAll(`td:nth-child(3) item-brewing-table`).forEach(output => {
  1021. const label = output.getAttribute("data-materials-item").replaceAll("_", " ")
  1022. output.textContent = `${Number(output.textContent).toLocaleString()} (${label})`
  1023. })
  1024. })
  1025. }
  1026.  
  1027. create_machinery_arrow_template() {
  1028. const arrow_template_str = `
  1029. <template id="uit_arrow_template">
  1030. <div class="arrow-controls" onclick="event.stopPropagation()">
  1031. <div class="arrow up"></div>
  1032. <item-display data-format="number">1</item-display>
  1033. <div class="arrow down"></div>
  1034. </div>
  1035. </template>
  1036. `
  1037. $("body").append($(arrow_template_str))
  1038. }
  1039.  
  1040. add_mining_machine_arrows() {
  1041. const machineryList = [
  1042. "drill",
  1043. "crusher",
  1044. "giant_drill",
  1045. "excavator",
  1046. "giant_excavator",
  1047. "massive_excavator",
  1048. ]
  1049.  
  1050. document.querySelector("#panel-mining").classList.add("add-arrow-controls")
  1051.  
  1052. const template = document.getElementById("uit_arrow_template")
  1053.  
  1054. machineryList.forEach((machine) => {
  1055. const itemBox = document.querySelector(`itembox[data-item=${machine}]`)
  1056. let clone = template.content.cloneNode(true)
  1057. if (itemBox) {
  1058. clone.querySelector(".up").onclick = function (event) {
  1059. event.stopPropagation()
  1060. IdlePixelPlus.sendMessage(`MACHINERY=${machine}~increase`)
  1061. }
  1062.  
  1063. clone.querySelector("item-display").setAttribute("data-key", `${machine}_on`)
  1064.  
  1065. clone.querySelector(".down").onclick = function (event) {
  1066. event.stopPropagation()
  1067. IdlePixelPlus.sendMessage(`MACHINERY=${machine}~decrease`)
  1068. };
  1069.  
  1070. itemBox.appendChild(clone)
  1071. }
  1072. })
  1073. }
  1074.  
  1075. make_uuid_clickable() {
  1076. const regex = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
  1077. let chatArea = document.getElementById("chat-area");
  1078. let lastMessageElement = chatArea.lastChild;
  1079. let player = lastMessageElement.querySelector('.chat-username').innerText;
  1080.  
  1081. if (lastMessageElement && 'innerHTML' in lastMessageElement) {
  1082. let lastMessage = lastMessageElement.innerHTML
  1083. lastMessage = lastMessage.replace(regex, function (match) {
  1084. return `<a href="#" class="raid-link" onclick="IdlePixelPlus.plugins['ui-tweaks-lite'].click_raid_link(event)" data-uuid="${match}">${player} Raid</a>`;
  1085. })
  1086. lastMessageElement.innerHTML = lastMessage;
  1087. }
  1088. }
  1089.  
  1090. click_raid_link(event) {
  1091. event.preventDefault()
  1092. websocket.send(`JOIN_RAID_TEAM=${event.target.dataset.uuid}`)
  1093. switch_panels('panel-combat');
  1094. document.getElementById('game-panels-combat-items-area').style.display = 'none';
  1095. document.getElementById('combat-stats').style.display = 'none';
  1096. document.getElementById('game-panels-combat-raids').style.display = '';
  1097. }
  1098.  
  1099. add_dividers_to_left_menu() {
  1100. document.getElementById("left-menu-bar-labels").classList.add("left_menu_divider")
  1101. document.getElementById("left-panel-item_panel-teams")?.classList.add("left_menu_divider")
  1102. document.getElementById("left-panel-item_panel-magic").classList.add("left_menu_divider")
  1103. document.getElementById("left-panel-item_panel-criptoe-market").classList.add("left_menu_divider")
  1104. }
  1105.  
  1106. clone_dust_pots() {
  1107. const dust_pots = document.getElementById("panel-brewing").querySelectorAll(".dust-box")
  1108. dust_pots.forEach((element) => {
  1109. if (element.dataset.item.startsWith("cooks")) {
  1110. const chefs_hat = document.getElementById("panel-cooking").querySelector('itembox[data-item="chefs_hat"]')
  1111. const clone = element.cloneNode(true)
  1112. chefs_hat.insertAdjacentElement("afterend", clone)
  1113. clone.insertAdjacentHTML("beforebegin", `\n\n`)
  1114. }
  1115. if (element.dataset.item.startsWith("tree")) {
  1116. const chop_all_tree = document.getElementById("panel-woodcutting").querySelector('itembox[data-item="chop_all_ent_special"]')
  1117. const clone = element.cloneNode(true)
  1118. chop_all_tree.insertAdjacentElement("afterend", clone)
  1119. clone.insertAdjacentHTML("beforebegin", `\n\n`)
  1120. }
  1121. if (element.dataset.item.startsWith("fight")) {
  1122. const combat_badges = document.getElementById("combat-badge-itembox")
  1123. const clone = element.cloneNode(true)
  1124. combat_badges.insertAdjacentElement("beforebegin", clone)
  1125. clone.insertAdjacentHTML("afterend", `\n\n`)
  1126. }
  1127. if (element.dataset.item.startsWith("farm")) {
  1128. const compactor = document.getElementById("panel-farming").querySelector('itembox[data-item="seed_compactor"]')
  1129. const clone = element.cloneNode(true)
  1130. compactor.insertAdjacentElement("afterend", clone)
  1131. clone.insertAdjacentHTML("beforebegin", `\n\n`)
  1132. }
  1133. })
  1134. }
  1135.  
  1136. add_extra_data_to_combat(){
  1137. const extra_data = `
  1138. <br>
  1139. <div class="td-combat-stat-entry">
  1140. <img class="img-15" src="https://cdn.idle-pixel.com/images/combat_loot_potion.png" title="combat_loot_potion">
  1141. <span style="color:white">Loot Pot: </span>
  1142. <span id="combat_info_loot_pot"></span>
  1143. </div>
  1144. <div class="td-combat-stat-entry">
  1145. <img class="img-15" src="https://cdn.idle-pixel.com/images/rare_monster_potion.png" title="rare_monster_potion">
  1146. <span style="color:white">Rare Pot: </span>
  1147. <span id="combat_info_rare_pot"></span>
  1148. </div>
  1149. <div class="td-combat-stat-entry">
  1150. <img class="img-15" src="https://cdn.idle-pixel.com/images/fight_points.png" title="fight_points">
  1151. <span style="color:white">FP: </span>
  1152. <span id="combat_info_fps"></span>
  1153. </div>
  1154. `
  1155. document.getElementById("menu-bar-idle-hero-arrows-area-2").insertAdjacentHTML("afterend", extra_data)
  1156. }
  1157.  
  1158. create_mixer_notification(){
  1159. const potion_element = document.getElementById("notification-potion-guardian_key_potion_timer")
  1160. let clone = potion_element.cloneNode(true)
  1161. clone.id = "uit_notification_mixer"
  1162. clone.style = ""
  1163. clone.classList.add("hover")
  1164.  
  1165. let img = clone.querySelector("img")
  1166. img.setAttribute("src", get_image("images/brewing_xp_mixer.png"))
  1167. img.setAttribute("title", "Brewing Mixer")
  1168.  
  1169. clone.querySelector("item-display").setAttribute("data-key", "next_day_timer")
  1170.  
  1171. let span = clone.querySelector("span")
  1172. span.id = ""
  1173. span.innerHTML = `<item-display data-format="number" data-key="mixer_charges_remaining"></item-display>/5`
  1174.  
  1175. clone.onclick = function () {Modals.clicks_brewing_xp_mixer();}
  1176. potion_element.insertAdjacentElement("afterend", clone)
  1177. }
  1178.  
  1179. create_merchant_notification(){
  1180. const ready_element = document.getElementById("notification-robot_waves-ready")
  1181. let clone = ready_element.cloneNode(true)
  1182. clone.id = "uit_notification_merchant"
  1183. clone.style.display = ""
  1184.  
  1185. let img = clone.querySelector("img")
  1186. img.setAttribute("src", get_image("images/merchant.png"))
  1187. img.setAttribute("title", "Merchant")
  1188.  
  1189. img.insertAdjacentHTML("afterend", `<item-display class="color-white" data-format="timer" data-key="merchant_timer"></item-display>`)
  1190.  
  1191. clone.querySelector("span").remove()
  1192.  
  1193. clone.onclick = function () {switch_panels("panel-shop");}
  1194.  
  1195. ready_element.insertAdjacentElement("afterend", clone)
  1196. }
  1197.  
  1198. create_oil_notification(){
  1199. const notification = `
  1200. <div id="uit_notification_oil" class="notification hover">
  1201. <img src="${get_image("images/oil.png")}" class="w20" title="Oil Delta">
  1202. <item-display id="uit_oil_notif_label" class="color-white" data-key="uit_oil_notif_label">0</item-display>
  1203. <item-display id="uit_oil_notif_timer" class="color-white" data-format="timer" data-key="uit_oil_notif_timer">0</item-display>
  1204. </div>`
  1205. document.getElementById("notification-massive_excavator").insertAdjacentHTML("afterend", notification)
  1206. }
  1207.  
  1208. update_oil_notification(){
  1209. const oil = parseInt(window.var_oil)
  1210. const oil_delta = parseInt(window.var_oil_in) - parseInt(window.var_oil_out)
  1211. window.var_oil_delta = `${oil_delta}`
  1212. const max_oil = parseInt(window.var_max_oil)
  1213. window.var_uit_oil_notif_label = ""
  1214. if (oil_delta===0){
  1215. window.var_uit_oil_notif_label = "Balanced"
  1216. document.getElementById("uit_oil_notif_timer").style.display = "none"
  1217. } else if (oil_delta>0){
  1218. if(oil >= max_oil){
  1219. window.var_uit_oil_notif_label = "Oil Full"
  1220. document.getElementById("uit_oil_notif_timer").style.display = "none"
  1221. } else {
  1222. window.var_uit_oil_notif_label = "Oil Increasing"
  1223. window.var_uit_oil_notif_timer = `${(max_oil - oil) / oil_delta}`
  1224. document.getElementById("uit_oil_notif_timer").style.display = ""
  1225. document.getElementById("uit_oil_notif_timer").style.color = "green"
  1226. }
  1227. } else {
  1228. if(oil <= 0){
  1229. window.var_uit_oil_notif_label = "Oil Empty"
  1230. document.getElementById("uit_oil_notif_timer").style.display = "none"
  1231. } else {
  1232. window.var_uit_oil_notif_label = "Oil Decreasing"
  1233. window.var_uit_oil_notif_timer = `${oil / -oil_delta}`
  1234. document.getElementById("uit_oil_notif_timer").style.display = ""
  1235. document.getElementById("uit_oil_notif_timer").style.color = "red"
  1236. }
  1237. }
  1238. }
  1239.  
  1240. add_timer_to_smelt_notification(){
  1241. const timer_html = ` (<item-display class="color-white" data-format="timer" data-key="furnace_timer_remaining"></item-display>)`
  1242. document.getElementById("notification-furnace-running").querySelector("span").insertAdjacentHTML("afterend", timer_html)
  1243. }
  1244.  
  1245. handle_smelt_timer(valueBefore, valueAfter){
  1246. if(valueAfter === "none"){
  1247. if(this.smelt_timer){
  1248. clearInterval(this.smelt_timer)
  1249. this.smelt_timer = null
  1250. }
  1251. } else if (valueBefore !== valueAfter && valueAfter) {
  1252. const bar_time = this.smelt_times[valueAfter]
  1253. const bars_to_smelt = parseInt(window.var_furnace_ore_amount_set)
  1254. if(this.smelt_timer){ // Just in case
  1255. clearInterval(this.smelt_timer)
  1256. this.smelt_timer = null
  1257. }
  1258. window.var_furnace_timer_remaining = `${bar_time * bars_to_smelt}`
  1259. this.smelt_timer = setInterval(() => {
  1260. const new_time = parseInt(window.var_furnace_timer_remaining) - 1
  1261. window.var_furnace_timer_remaining = `${new_time}`
  1262.  
  1263. if(new_time <= 0){
  1264. clearInterval(this.smelt_timer)
  1265. this.smelt_timer = null
  1266. }
  1267. }, 1000)
  1268. }
  1269. }
  1270.  
  1271. hide_active_machinery(){
  1272. const machinery_list = ["drill", "crusher", "giant_drill", "excavator", "giant_excavator", "massive_excavator"]
  1273.  
  1274. machinery_list.forEach(machine => {
  1275. document.getElementById(`notification-${machine}`).classList.add("uit_hidden")
  1276. })
  1277. }
  1278.  
  1279. fix_left_menu(){
  1280. document.getElementById("left-panel-item_panel-archery").classList.remove("game-menu-bar-left-table-btn-borderless")
  1281. document.getElementById("left-panel-item_panel-archery").classList.add("game-menu-bar-left-table-btn")
  1282. document.getElementById("left-panel-item_panel-magic").classList.remove("game-menu-bar-left-table-btn-borderless")
  1283. document.getElementById("left-panel-item_panel-magic").classList.add("game-menu-bar-left-table-btn")
  1284.  
  1285. let labels = document.getElementById("left-menu-bar-labels");
  1286. labels.style.padding = "unset";
  1287. }
  1288.  
  1289. create_left_menu_extras(){
  1290. const container_html = `<div style="padding: unset;" class="left_menu_divider" id="left_menu_extras"></div>`
  1291. document.getElementById("left-menu-bar-labels").insertAdjacentHTML("afterend", container_html)
  1292.  
  1293. const rocket_html = `<div style="padding: unset;" class="left_menu_divider" id="left_menu_rocket_extras"></div>`
  1294. document.getElementById("left_menu_extras").insertAdjacentHTML("afterend", rocket_html)
  1295.  
  1296. const lower_top_bar = document.getElementById("top-menu-bar-optional-labels")
  1297.  
  1298. const top_extras = lower_top_bar.querySelectorAll(".top-bar-entry")
  1299.  
  1300. top_extras.forEach(element => {
  1301. let new_element = element.cloneNode(true);
  1302. const orig_id = new_element.id
  1303. new_element.id = ""
  1304. new_element.classList.remove("top-bar-entry")
  1305. new_element.classList.add("left-menu-item")
  1306.  
  1307. if(orig_id.startsWith("rocket")){
  1308. new_element.classList.add("hover")
  1309. new_element.setAttribute("onclick", "Modals.clicks_rocket()")
  1310. document.getElementById("left_menu_rocket_extras").appendChild(new_element)
  1311. } else {
  1312. document.getElementById("left_menu_extras").appendChild(new_element)
  1313. }
  1314. })
  1315.  
  1316. this.update_css(".game-top-bar-optional-lower", "display", "none")
  1317. }
  1318.  
  1319. purple_key_extras(){
  1320. const purple_key_element = document.getElementById("guardian-key-3-extra-label")
  1321.  
  1322. purple_key_element.classList.add("hover")
  1323.  
  1324. purple_key_element.setAttribute("onclick", `websocket.send("CASTLE_MISC=guardian_purple_key_hint")`)
  1325.  
  1326. const timer_html = ` ⏲️<item-display data-format="timer" data-key="nades_purple_key_timer"></item-display>`
  1327. purple_key_element.querySelector("span").insertAdjacentHTML("afterend", timer_html)
  1328. }
  1329.  
  1330. rocket_extras(){
  1331. const top_moon = document.getElementById("rocket-distance-extra-label-moon")
  1332. top_moon.classList.add("hover")
  1333. top_moon.setAttribute("onclick", "Modals.clicks_rocket()")
  1334.  
  1335. const top_sun = document.getElementById("rocket-distance-extra-label-sun")
  1336. top_sun.classList.add("hover")
  1337. top_sun.setAttribute("onclick", "Modals.clicks_rocket()")
  1338.  
  1339. const fuel_element = $.parseHTML(
  1340. `<div class="left-menu-item hover" id="left_menu_fuel">
  1341. <img src="${get_image("images/rocket_fuel.png")}" title="fuel" class="w20">
  1342. <span>Rocket Fuel - </span>
  1343. <item-display data-format="number" data-key="rocket_fuel"></item-display>
  1344. </div>`
  1345. )
  1346. const rocket_container = $("#left_menu_rocket_extras")
  1347. rocket_container.append(fuel_element)
  1348.  
  1349. document.getElementById("left_menu_fuel").addEventListener("click", ()=>{
  1350. Modals.open_input_dialogue("rocket_fuel", "Crafting", "How many do you want to craft?", "CRAFT")
  1351. })
  1352.  
  1353. const rocket_pot_element = $.parseHTML(
  1354. `<div class="left-menu-item hover" id="left_menu_rocket_pot">
  1355. <img src="${get_image("images/rocket_potion.png")}" title="rocket potion" class="w20">
  1356. <span>Rocket Potion - </span>
  1357. <item-display data-format="number" data-key="rocket_potion"></item-display>
  1358. </div>`
  1359. )
  1360. rocket_container.append(rocket_pot_element)
  1361.  
  1362. document.getElementById("left_menu_rocket_pot").addEventListener("click", ()=>{
  1363. if(window.var_rocket_potion > 0){
  1364. Brewing.potion_clicked("rocket_potion")
  1365. } else {
  1366. Modals.open_brew_dialogue("rocket_potion")
  1367. }
  1368. })
  1369. }
  1370.  
  1371. update_moon_colour(){
  1372. const moon_dist = parseInt(window.var_moon_distance)
  1373. if(moon_dist <= this.settings.get("good_moon")){
  1374. this.update_css(".moon_distance", "color", "lime")
  1375. } else {
  1376. this.update_css(".moon_distance", "color", "red")
  1377. }
  1378. }
  1379.  
  1380. update_sun_colour(){
  1381. const sun_dist = parseInt(window.var_sun_distance)
  1382. if(sun_dist <= this.settings.get("good_sun")){
  1383. this.update_css(".sun_distance", "color", "lime")
  1384. } else {
  1385. this.update_css(".sun_distance", "color", "red")
  1386. }
  1387. }
  1388.  
  1389. update_ui() {
  1390. this.condense_woodcutting_patches()
  1391. this.condense_farming_patches()
  1392. this.condense_gathering_boxes()
  1393. this.give_images_titles()
  1394. this.add_labels_to_table_items()
  1395. this.condense_ui()
  1396. this.create_machinery_arrow_template()
  1397. this.add_mining_machine_arrows()
  1398. this.restructure_chat()
  1399. this.move_plugins_button()
  1400. this.show_extended_levels()
  1401. this.add_dividers_to_left_menu()
  1402. this.clone_dust_pots()
  1403. this.add_extra_data_to_combat()
  1404. this.hide_active_machinery()
  1405. this.create_mixer_notification()
  1406. this.create_merchant_notification()
  1407. this.fix_left_menu()
  1408. this.create_oil_notification()
  1409. this.add_timer_to_smelt_notification()
  1410. this.purple_key_extras()
  1411. this.create_left_menu_extras()
  1412. this.rocket_extras()
  1413. }
  1414.  
  1415. criptoe_extras(){
  1416. const clock = `<item-display data-format="timer" data-key="utc_time"></item-display>`
  1417. document.getElementById("criptoe_path_selected-left-label").insertAdjacentHTML("beforebegin", clock)
  1418. const now = new Date()
  1419. window.var_utc_time = `${now.getUTCHours() * 3600 + now.getUTCMinutes() * 60 + now.getUTCSeconds()}`
  1420.  
  1421. this.utc_clock = setInterval(() => {
  1422. let new_time = parseInt(window.var_utc_time) + 1
  1423. if (new_time >= 86400){
  1424. new_time = 0
  1425. }
  1426. window.var_utc_time = `${new_time}`
  1427. }, 1000)
  1428.  
  1429. const wallets = document.getElementById("panel-criptoe-market").querySelectorAll(".CToe-chart-table")
  1430. wallets.forEach((wallet, idx)=>{
  1431. const previous_element = wallet.querySelector("item-display")
  1432. const returns_element = `<br><b>Current Payout: </b><span id="wallet_${idx+1}_payout"></span>`
  1433. previous_element.insertAdjacentHTML("afterend", returns_element)
  1434. })
  1435. }
  1436.  
  1437. update_criptoe_payouts(){
  1438. const test = document.getElementById(`criptoe-wallet-1-percentage`).innerText
  1439. if(test==="%0.00"){
  1440. setTimeout(IdlePixelPlus.plugins["ui-tweaks-lite"].update_criptoe_payouts, 1000)
  1441. return
  1442. }
  1443. const wallets = document.getElementById("panel-criptoe-market").querySelectorAll(".CToe-chart-table")
  1444. wallets.forEach((wallet, idx)=>{
  1445. let payout
  1446. const invested = parseInt(window[`var_wallet${idx+1}_invested`]) || 0
  1447.  
  1448. if (invested===0){
  1449. payout = "No investment"
  1450. } else {
  1451. let percentage = document.getElementById(`criptoe-wallet-${idx+1}-percentage`).innerText.split(" ")[0]
  1452. percentage = 1 + (parseFloat(percentage) / 100)
  1453.  
  1454. if (percentage <= -100) {
  1455. payout = "No return"
  1456. } else {
  1457. payout = `${Math.floor(percentage * invested).toLocaleString()}`
  1458. }
  1459. }
  1460.  
  1461. document.getElementById(`wallet_${idx+1}_payout`).innerText = payout
  1462. })
  1463. }
  1464.  
  1465. limitChat() {
  1466. const chatArea = document.getElementById("chat-area");
  1467. const chatLength = chatArea.innerHTML.length;
  1468.  
  1469. if (chatLength > 190000) {
  1470. const children = chatArea.children;
  1471.  
  1472. for (let i = 0; i < 3; i++) {
  1473. try {
  1474. chatArea.removeChild(children[i]);
  1475. } catch (err) {
  1476. console.error("Error cleaning up chat", err);
  1477. }
  1478. }
  1479. }
  1480. }
  1481.  
  1482. onLogin() {
  1483. Paneller.registerPanel("uit_lite_settings", "UIT Lite Settings", IdlePixelPlus.plugins["ui-tweaks-lite"].show_modal)
  1484. this.get_font_list()
  1485. this.create_settings_modal()
  1486. this.apply_set_styles()
  1487. this.update_ui()
  1488. this.criptoe_extras()
  1489.  
  1490. window.var_mixer_charges_remaining = 5
  1491. window.var_uit_oil_notif_label = "Balanced"
  1492.  
  1493. this.loaded = true
  1494. }
  1495.  
  1496. onChat(data) {
  1497. IdlePixelPlus.plugins["ui-tweaks-lite"].limitChat()
  1498. this.make_uuid_clickable()
  1499. }
  1500.  
  1501. onPanelChanged(panelBefore, panelAfter) {
  1502. if (panelAfter === "combat-canvas-raids" || panelAfter === "combat-canvas") {
  1503. document.getElementById("game-chat").style.display = ""
  1504. }
  1505. if (panelAfter === "combat-canvas") {
  1506. document.getElementById("combat_info_fps").textContent = window.var_fight_points
  1507. document.getElementById("combat_info_rare_pot").textContent = window.var_rare_monster_potion_timer || "Inactive"
  1508. document.getElementById("combat_info_loot_pot").textContent = window.var_combat_loot_potion_active === "1" ? "Active" : "Inactive"
  1509. }
  1510. if (panelAfter === "criptoe-market"){
  1511. this.update_criptoe_payouts()
  1512. }
  1513. }
  1514.  
  1515. onVariableSet(key, valueBefore, valueAfter) {
  1516. if(!this.loaded){return;}
  1517. if (Globals.currentPanel === "panel-combat-canvas") {
  1518. if (key === "fight_points") {
  1519. document.getElementById("combat_info_fps").textContent = `${valueAfter.toLocaleString()}`
  1520. } else if (key === "rare_monster_potion_timer") {
  1521. document.getElementById("combat_info_rare_pot").textContent = valueAfter
  1522. } else if (key === "combat_loot_potion_active") {
  1523. document.getElementById("combat_info_loot_pot").textContent = valueAfter === "1" ? "Active" : "Inactive"
  1524. }
  1525. }
  1526.  
  1527. if (key==="playtime"){
  1528. window.var_next_day_timer = 86400 - valueAfter % 86400
  1529. }
  1530. else if (key==="brewing_xp_mixer_used"){
  1531. window.var_mixer_charges_remaining = 5 - valueAfter
  1532. }
  1533. else if (key === "oil"){
  1534. this.update_oil_notification()
  1535. }
  1536. else if (key === "furnace_ore_type"){
  1537. this.handle_smelt_timer(valueBefore, valueAfter)
  1538. }
  1539. else if (key === "moon_distance"){
  1540. this.update_moon_colour()
  1541. }
  1542. else if (key === "sun_distance"){
  1543. this.update_sun_colour()
  1544. }
  1545. }
  1546. }
  1547.  
  1548. const plugin = new UITweaksPlugin();
  1549. IdlePixelPlus.registerPlugin(plugin);
  1550. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址