// ==UserScript== // @name Panel Dodatków NI // @namespace http://the-crudness.xaa.pl/NIAddons/panel.user.js // @version 2.5 // @description Dodaje do wbudowanego panelu dodatków inne dodatki. // @author Priveeq // @include http://aldous.margonem.pl/ // @include http://tempest.margonem.pl/ // @include http://mordor.margonem.pl/ // @include http://invisible.margonem.pl/ // @include http://dionizos.margonem.pl/ // @include http://genos.margonem.pl/ // @include http://majorka.margonem.pl/ // @include http://aequus.margonem.pl/ // @include http://experimental-ni.margonem.pl/ // @include http://husaria.margonem.com/ // @include http://cronus.margonem.com/ // @grant none // ==/UserScript== // ==Changelog== // 2.5 - znów pełno zmian w API, kolejny nowy dodatek // 2.4 - pierdyliard zmian w API, nowy dodatek, usunięte na obecną chwile dodatki darrefulla bo mu hosting padł czy coś // 2.3 - nowy dodatek, naprawione loader.require // 2.2 - włączenie dodatku pokazywanie kolizji dla angielskiego margonem, bo działają już tam widgety. Trochę wewnętrznych zmian w tym skrypcie // 2.1 - dodatek lepsza walka, trochę zmian w tym kodzie żeby łatwiej się robiło dodatki (event emmitery anyone?) // 2.0.1 - pierwsza nietestowa wersja // ==/Changelog== window.priwAddons = new (function() { var addons = this; window.API.priw = this; var Storage = API.Storage; var Templates = API.Templates; this.list = { priw_clbl: { namePL: "Błoga klanowe", nameEN: "Guild blessings", descPL: "Dodaje pod torbami panel wyboru błogosławieństwa klanowego, taki skrót. Nie ma sensu instalować na nakładce NI, bo w starym systemie klanów tych błogosławieństw nie ma.", descEN: "Adds shortcuts to guild blessings under the bags.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/NIblesspanel.js?", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/NIblesspanel.js?", img: "http://aldous.margonem.pl/img/gui/buttony.png?v=4|-561 -12", author: "Priveeq|3779166" }, priw_ntpd: { namePL: "Notatnik", nameEN: "Notepad", descPL: "Dodaje prosty notatnik, dostępny pod torbami.", descEN: "Adds a simple notepad under the bags.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/notepadNI.js?", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/notepadNI.js?", img: "http://aldous.margonem.pl/img/gui/buttony.png?v=4|-437 -12", author: "Priveeq|3779166" }, priw_extl: { namePL: "Instalator zewnętrznych skryptów", nameEN: "External script loader", descPL: "Pozwala instalować zewnętrzne dodatki przez wpisanie adresu do skryptu. Wygląda to tak.", descEN: "Allows installing external scripts from a given url, as shown here.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/NIextLoader.js?", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/NIextLoader.js?", img: "http://aldous.margonem.pl/img/gui/buttony.png?v=4|-282 -12", author: "Priveeq|3779166", widget: { color: "blue", } }, priw_obw: { namePL: "Lepsza walka", nameEN: "Better battle", descPL: "Dodaje następujące rzeczy do walki:
-animowanie przesuwania się postaci
-bardziej widoczne pokazywanie naszej tury
-mniejsze odległości między postaciami w walce
-ilość życia, many i energii w tipach (dymkach) nad postaciami
-wybór umiejętności jak na starym interfejsie (można wyłączyć w dolnej części konfiguracji gry)", descEN: "Adds following features to the battle window:
-characters now move smoothly from place to place, instead of teleporting
-better indication of player's turn
-distance between characters is smaller
-health, energy and mana is shown in tooltips above characters
-alternative skill selection method, samilar to how it was on the old interface (this feature can be disabled at the bottom of game config)", //urlPL: "http://192.168.0.110:1337/NIoldBattle.js", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/NIoldBattle.js?7", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/NIoldBattle.js?7", img: "http://aldous.margonem.pl/img/gui/addons-icons.png|-4 -34", author: "Priveeq|3779166" }, priw_mmp: { namePL: "miniMap+", nameEN: "miniMap+", descPL: "Dodaje do gry wielofunkcyjną minimapę. Domyślnie otwiera sie klawiszem [R]", descEN: "Adds a multifunctional minimap. Default hotkey to open it is set to [R]. Note that it hasn't been translated to english.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/miniMapPlusNI.js", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/miniMapPlusNI.js", img: "http://aldous.margonem.pl/img/gui/buttony.png|-158 -12", author: "Priveeq|3779166" }, priw_tth: { namePL: "Titan Helper+", nameEN: "Titan Helper+", descPL: "Pokazuje w oknie walki użyteczne informacje (ilość tur od użycia aury SA, aktualnie ładowany atak specjalny tytana itp)", descEN: "Shows some useful info in the battle window (amount of turns that has passed since someone used attack speed aura, spell that is currently being charged by a titan etc). It hasn't been translated from polish, but I think it should be easy enough to figure out what it shows.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/titanHelperPlusNI.js", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/titanHelperPlusNI.js", img: "http://aldous.margonem.pl/img/gui/addons-icons.png|-4 -34", author: "Priveeq|3779166" }, priw_sf: { namePL: "ShopFilter", nameEN: "ShopFilter", descPL: "Dodaje do sklepów dodatkowe opcje filtrowania.", descEN: "Adds additional filters to shops.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/shopFilterNI.js", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/shopFilterNI.js", img: "http://aldous.margonem.pl/img/gui/addons-icons.png|-128 -3", author: "Priveeq|3779166" }, priw_sakwa: { namePL: "Sakwa", nameEN: "Pouch", descPL: "Przywraca funkcjonalną sakwę ze starego interfejsu.", descEN: "Restores a functional pouch from the old interface.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/pouch.js", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/pouch.js", img: "/obrazki/npc/mas/nic32x32.gif", author: "Priveeq|3779166" }, priw_h2h: { namePL: "https2http", nameEN: "https2http", descPL: "Linki które mają z przodu https nie działają na chacie. Dodatek zamienia w wysyłanych wiadomościach https na http i wtedy działają.", descEN: "Fixes a bizzare bug that causes links that contain https to not work by replacing https with http in sent messages.", urlPL: "http://the-crudness.xaa.pl/NIAddons/get/https2httpNI.js", urlEN: "http://the-crudness.xaa.pl/NIAddons/get/https2httpNI.js", img: "http://aldous.margonem.pl/img/gui/buttony.png?v=4|-406 -12", author: "Priveeq|3779166" }, groov_gll: { namePL: "Global lootlog", descPL: "Jest to dodatek, który umieszcza nasze looty heroiczne i legendarne na stronie, aby później móc je przeglądać. Podczas lootnięcia itemu zawsze mamy możliwość zdecydowania, czy ma on zostać tam dodany, czy też nie.

Dodatek zapisuje zdobycze ze światów publicznych i prywatnych.

Strona główna: http://grooove.pl/lootlog/", urlPL: "http://addons2.margonem.pl/get/70/70663dev.js", img: "http://aldous.margonem.pl/img/gui/buttony.png|-158 -12", author: "Groove Armada|3088295", beforeInstall: function() { if ($("#GLobalLootlogLauncher").length) { message("Global lootlog jest już zainstalowany z innego źródła."); return true; }; }, noEN: true }, groov_pw: { namePL: "Panel walk", nameEN: "Battle panel", descPL: "Dodatek automatycznie zapisuje walki z graczami na stronie, gdzie później ładnie je wyświetla.
Przykład: http://grooove.pl/battle/id-1", descEN: "This addon automatically saves battles aganist other players on a website, where they are nicely displayed.
Example: http://grooove.pl/battle/id-1", urlPL: "http://addons2.margonem.pl/get/70/70674dev.js", urlEN: "http://addons2.margonem.pl/get/70/70674dev.js", img: "http://aldous.margonem.pl/img/gui/addons-icons.png|-4 -34", author: "Groove Armada|3088295", beforeInstall: function() { if ($("#PWLauncher").length) { message("Panel walk jest już zainstalowany z innego źródła."); return true; }; }, }, groov_count: { namePL: "Licznik ubić by Groove", nameEN: "Kill counter", descPL: "Liczy ubicia elit, elit II, herosów, tytanów i eventowych potworów.

Aby zresetować licznik lub usunąć pojedynczy wpis, należy wejść na stronę http://grooove.pl/licznik/ i się zalogować.", descEN: "Counts how many times you've killed monsters with ranks above elite. To reset the counter or delete a single entry, you have to visit http://grooove.pl/licznik/ and log in.", urlPL: "http://addons2.margonem.pl/get/70/70632dev.js", urlEN: "http://addons2.margonem.pl/get/70/70688dev.js", img: "http://aldous.margonem.pl/img/gui/addons-icons.png|-97 -34", author: "Groove Armada|3088295", beforeInstall: function() { if ($("#GACounterLauncher").length) { message("Licznik ubić jest już zainstalowany z innego źródła."); return true; }; }, }, ake_coll: { namePL: "Pokazywanie kolizji", nameEN: "Show collisions", descPL: "Pokazuje kolizje na mapie.", descEN: "Shows map collisions.", urlPL: "http://addons2.margonem.pl/get/76/76788dev.js?3", urlEN: "http://addons2.margonem.pl/get/76/76788dev.js?3", img: "http://aldous.margonem.pl/img/gui/buttony.png|-702 -710", author: "Akechi|229327", widget: { color: "blue" } }, ccar_evo: { namePL: "Evolution Manager", nameEN: "Evolution Manager", descPL: "Wielofunkcyjny manager dodatków. Temat na forum.
Instaluje się jego osobny userscript.", descEN: "multifunctional addon manager. Polish forum thread.
Installs as a separate userscript.", urlPL: "http://m.ccrr.pl/evo/client/start.user.js", urlEN: "http://m.ccrr.pl/evo/client/start.user.js", img: "http://aldous.margonem.pl/img/gui/buttony.png|-437 -12", author: "Programista CcarderR|2210626", beforeInstall: function() { if (typeof (evoStart) != "undefined") { message("Evolution Manager jest już zainstalowany."); } else { window.open("http://m.ccrr.pl/evo/client/start.user.js"); }; return true; }, }, //eeeeeee darrowi padł hosting to na chwilę obecną wywalam z panelu /*darr_mm: { namePL: "Margomap", nameEN: "Margomap", descPL: "Prosta minimapa, otwiera się przyciskiem [E]", descEN: "A simple minimap, can be opened with the [E] button.", urlPL: "http://addons2.margonem.pl/get/77/77011dev.js?3", urlEN: "http://addons2.margonem.pl/get/77/77011dev.js?3", data: "http://addons2.darro.eu/js/margomap.js", img: "http://aldous.margonem.pl/img/gui/buttony.png|-158 -12", author: "Darrefull|359424", beforeInstall: function() { if (typeof window.DMargoMap != "undefined") { message("Margomap jest już zainstalowany z innego źródła."); return true; }; }, }, darr_akh: { namePL: "Licznik Akh-Mater", descPL: "Liczy nawróconych i zapytanych do questa Słowo Akh-Mater..", urlPL: "http://addons2.margonem.pl/get/77/77011dev.js?3", data: "http://addons2.darro.eu/js/akh-mater.js", img: "http://aldous.margonem.pl/img/gui/buttony.png|-189 -12", author: "Darrefull|359424", beforeInstall: function() { if ($("div[data-tip*='Licznik do questa
Słowo Akh-Mate']").length > 0) { message("Licznik Akh-Mater jest już zainstalowany z innego źródła."); return true; }; }, noEN: true }, darr_coun: { namePL: "Licznik ubić by Darrefull", descPL: "Liczy ubicia elit/e2/herosów/tytanów.", urlPL: "http://addons2.margonem.pl/get/77/77011dev.js?3", data: "http://addons2.darro.eu/js/counter.js", img: "http://aldous.margonem.pl/img/gui/addons-icons.png|-97 -34", author: "Darrefull|359424", beforeInstall: function() { if (typeof window.eCounter != "undefined") { message("Licznik ubić by Darrefull jest już zainstalowany z innego źródła."); return true; }; }, noEN: true }*/ }; this.addonIds = Object.keys(this.list); this.storageKey = "priwAddons"; this.getStorage = function() { if (!this.storageCache) { this.storageCache = localStorage.getItem(this.storageKey) ? JSON.parse(localStorage.getItem(this.storageKey)) : []; }; return this.storageCache; }; this.setStorage = function(storage) { this.storageCache = storage; localStorage.setItem(this.storageKey, JSON.stringify(storage)); }; this.fixStorage = function() { var storage = this.getStorage(); var len = storage.length; for (var i=0; i -1); }; this.toggleAddon = function(id) { var storage = this.getStorage(); if (storage.indexOf(id) > -1) { storage.splice(storage.indexOf(id), 1); } else { storage.push(id); }; this.setStorage(storage); }; this.fixStorage(); this.loader = new (function(_ajax){ var self = this; this.addonsLoaded = 0; this.waitForInterfaceChanger = false; //eliminuje potencjalną możliwość zagryzienia się z dodatkiem SI2NI if (typeof __bootNI != "undefined" && __bootNI) { var _reCallInitQueue = Engine.reCallInitQueue; this.waitForInterfaceChanger = true; Engine.reCallInitQueue = function() { //funckja ta zostaje uruchomiona przez SI2NI gdy skończy ładować swoje dodatki self.waitForInterfaceChanger = false; Engine.reCallInitQueue = _reCallInitQueue; self.loadAddon(); }; }; $.ajax = function(options) { if (self.addonsLoaded < addons.addonIds.length && options.url.indexOf("engine?t=init") > -1) { self.loadAddon(); return; } else if (options.url.indexOf("margonem.pl/config.php") > -1) { var oldsuccess = options.success; options.success = function(data) { addons.afterGameBoot(); var ret = oldsuccess.apply(this, arguments); addons.afterInterfaceLoad(); return ret; }; } else if (options.url.indexOf("engine?t=") > -1) { var oldsuccess = options.success; var url = options.url; options.success = function(data) { var ret = oldsuccess.apply(this, arguments); addons.callbackParser(data, url); return ret; }; }; return _ajax.apply(this, arguments); }; this.loadAddon = function() { var id = addons.addonIds[this.addonsLoaded]; if (addons.getAddonState(id)) { var addon = addons.list[id]; if (addon.beforeInstall && addon.beforeInstall()) { //failsafe jakby ktoś coś odwalił addons.toggleAddon(id); return this.onAddonLoad(); }; if (!$.cachedScript) jQuery.cachedScript=function(e,c){return c=$.extend(c||{},{dataType:"script",cache:!0,url:e}),jQuery.ajax(c)}; var url = this.getUrl(addon); window.__currentAddon = { id: addons.addonIds[this.addonsLoaded], data: addon.data }; if (url.indexOf("?") > -1) url += "&v="+((new Date()).toLocaleDateString()); else url += "?v="+((new Date()).toLocaleDateString()); $.cachedScript(url).done(this.onAddonLoad).fail((xhr) => this.failedAddonLoad(id, xhr)); //$.getScript(url).done(this.onAddonLoad).fail((xhr) => this.failedAddonLoad(id, xhr)); } else { this.onAddonLoad(); }; }; this.onAddonLoad = function() { self.addonsLoaded++; if (self.addonsLoaded < addons.addonIds.length) { self.loadAddon(); } else { self.loadExtraAddons(); }; }; var extraLoadFinished = false; var extraAddonsLoaded = -1; this.loadExtraAddons = function() { extraAddonsLoaded++; if (extraAddonsLoaded < extraAddons.length) { var url = extraAddons[extraAddonsLoaded]; $.cachedScript(url).done(self.loadExtraAddons).fail((xhr) => self.failedExtraAddonLoad(url, xhr)); } else { if (!self.waitForInterfaceChanger) { extraLoadFinished = true; Engine.reCallInitQueue(); }; }; }; this.require = function(url) { if (!extraLoadFinished) extraAddons.push(url); else throw "Ładowanie już się zakończyło."; }; var extraAddons = []; this.failedAddonLoad = function(id, xhr) { var addon = addons.list[id]; if (_l() == "pl") console.warn("Nie udało się załadować dodatku "+addon.namePL+" ["+this.getUrl(addon)+"] ("+xhr.status + " - "+xhr.statusText+")"); else console.warn("Failed to load addon "+addon.nameEN+" ["+this.getUrl(addon)+"] ("+xhr.status + " - "+xhr.statusText+")"); this.onAddonLoad(); }; this.failedExtraAddonLoad = function(url, xhr) { if (_l() == "pl") console.warn("Nie udało się załadować skryptu z require "+url); else console.warn("Failed to load required script "+url); this.loadExtraAddons(); }; this.getUrl = function(addon) { return _l() == "pl" ? addon.urlPL : addon.urlEN; }; })($.ajax); var __g = _g; _g = function(url, extra) { var ret = addons.requestParser(url, extra); arguments[0] = ret[0]; arguments[1] = ret[1]; return __g.apply(this, arguments); }; this.requestParser = function(url, extra) { for (var i=0; i message("Dodatek zacznie działać po odświeżeniu gry") }; }; }; } else { _startAddonScript.apply(this, arguments); }; }; //dziwna różnica iędzy polskim a angielskim margonem if (Engine.addonsPanel.startAddonScript) { var _startAddonScript = Engine.addonsPanel.startAddonScript; Engine.addonsPanel.startAddonScript = fun; } else { var _startAddonScript = Engine.addonsPanel.turnOnAddon; Engine.addonsPanel.turnOnAddon = fun; }; var _turnOffAddon = Engine.addonsPanel.turnOffAddon; Engine.addonsPanel.turnOffAddon = function(id) { if (addons.isCustomAddon(id)) { if (addons.addedCustomAddons && addons.getAddonState(id)) { message(addons.reloadMsg); addons.toggleAddon(id); if (addons.list[id].widget) { $(".icon.addon_"+id).parent().remove(); if (API.Storage.get("hotWidget/addon_"+id)) API.Storage.remove("hotWidget/addon_"+id); }; }; } else { _turnOffAddon.apply(this, arguments); }; }; var _setStateAddon = Engine.addonsPanel.setStateAddon; Engine.addonsPanel.setStateAddon = function(state, id) { if (addons.isCustomAddon(id) && state && addons.addedCustomAddons) { var addon = addons.list[id]; if (addon.beforeInstall && addon.beforeInstall()) return; }; return _setStateAddon.apply(this, arguments); }; this.initCss(); for (var i=0; i -1); }; this.addCustomAddonsToList = function() { for (var i in this.list) { var addon = this.list[i]; if (_l() == "en" && addon.noEN) continue; if (_l() == "pl" && addon.noPL) continue; var author = addon.author.split("|"); var authorHtml = ""; var addonToAdd = { pl: { name: addon.namePL, description: addon.descPL + authorHtml }, en: { name: addon.nameEN, description: addon.descEN + authorHtml }, image: addon.img, options: addon.widget ? 1 : 0 }; Engine.addonsPanel.createOneAddonOnList(addonToAdd, i); Engine.addonsPanel.createOneAddonDescription(addonToAdd, i); } }; this.reloadMsg = _l() == "pl" ? "Zmiany będą widoczne po odświeżeniu gry..." : "Changes will come into effect once the page has been reloaded..."; this.initCss = function() { var css = ` .addon-author { font-size: 75%; text-align: right; color: #333333; } `; var widgets = {}; for (var i in this.list) { var addon = this.list[i]; if (!addon.widget) continue; if (addon.widget !== true) { widgets[i] = addon.widget; widgets[i].id = i; }; css += ` .icon.addon_`+i+` { background: `+Engine.addonsPanel.createBackgroundString(addon.img)+` !important; } `; }; this.emmiter.once("interface-load", ()=>this.widget.changeWidgetCss(widgets)); $("").appendTo("head"); }; //kod z Interface.showPopupMenu var $aLayer = $(document.getElementsByClassName("alerts-layer")[0]); this.popupMenu = function(menu, e) { if (!menu.length) return; var $m = $('
'); var $btn = API.Templates.get('button').addClass('small'); for (var i in menu) { (function (i) { var clone = $(''); if (isset(menu[i][2])) { clone.addClass(menu[i][2].button.cls); } $(clone).click(function (e) { if (menu[i][1]()) e.stopPropagation(); }); $m.append(clone); })(i); }; var zIndex = $aLayer.children().size() + 1; $aLayer.append($m); $m.css({ top: e.clientY - $m.height() / 2, left: e.clientX - $m.width() / 2, 'z-index': zIndex }).addClass('show'); }; document.addEventListener("click", () => { $('.custom-popup-menu').remove(); }) var $popupStyle = document.createElement("style"); //nie, nie mogę użyć normalnej klasy popup-menu bo gra kasuje element zanim mój eveneListener odpali ._. //nie rozumiem jakim prawem tak się dzieje, ale niektóre rzeczy trzeba po prostu przyjąć do wiadomości bez rozumienia $popupStyle.innerHTML = ` .custom-popup-menu { border: 5px solid; max-width: 150px; border-image: url(../img/gui/ramka.png) 6 repeat; -webkit-transform: scale(0); -webkit-transition: 0.2s linear; -webkit-transition-timing-function: cubic-bezier(0.68, 0.77, 0.4, 1.89); z-index: 1; background-color: #3F3B3D; background-clip: padding-box; pointer-events: auto; position: absolute; } .custom-popup-menu .menu-item { cursor: url(../img/gui/cursor/5.png), auto; padding: 2px 5px; display: block; margin-bottom: 1px; font-size: 12px; text-align: center; border-radius: 3px; background-color: #244518; color: white; border: 1px solid #396420; } .custom-popup-menu .menu-item:last-child { margin-bottom: 0px; } .custom-popup-menu .menu-item.label { cursor: url(../img/gui/cursor/1.png), auto; border: 0px; background-color: transparent; } .custom-popup-menu .menu-item:hover:not(.label) { border: 1px solid #4f7b21; background-color: #2e4f18; } .custom-popup-menu.show { -webkit-transform: scale(1); } .custom-popup-menu .s_cost { display: inline-block; margin-left: 5px; font-weight: bold; border: 1px solid rgba(0, 0, 0, 0.3); border-radius: 3px; background-color: rgba(0, 0, 0, 0.2); padding: 0px 3px; color: lightblue; line-height: 15px; } `; document.head.appendChild($popupStyle); this.dictionary = new (function() { var list = {}; this.get = function(id, data) { var str = list[id]; if (!str) return "missing["+id+"]"; str = str[_l()]; if (!str) return "nolang["+id+"]"; for (var i in data) { str = str.replace(i, data[i]); }; return str; }; this.add = function(id, txt) { list[id] = txt; //txt = {en: "txten", pl: "txtpl"} }; this.addMany = function(data) { for (var i=0; i"; $extraSettings.appendChild($header); var $list = document.createElement("ul"); $list.classList.add("hero-options"); var html = "", setting, enabled; for (var i=0; i"+setting.txt+""; }; $list.innerHTML = html; $list.addEventListener("click", this.toggleSetting); $extraSettings.appendChild($list); }; this.toggleSetting = function(e) { for (var i=0; i -1) { custom[id] = widgets[id]; } } return custom; } this.add = function(widget) { if (!API.Storage.get("hotWidget/addon__custom_"+widget.id)) { var pos = this.generateWidgetPos(widget); if (pos) API.Storage.set("hotWidget/addon__custom_"+widget.id, pos); else return true; }; addedWidgets[widget.id] = widget; window["addon__custom_"+widget.id] = { manageVisible: widget.clb }; return false; } this.generateWidgetPos = function(widget) { if (widget.corner != "FREE") return [index, corner]; else return this.findFreeWidgetPosition(); } this.findFreeWidgetPosition = function() { var widgets = API.Storage.get("hotWidget"); for (var i=0; i<2; i++) { var pos1 = !i ? "top" : "bottom"; for (var j=0; j<2; j++) { var pos2 = !j ? "left" : "right"; for (var k=0; k<2; k++) { if (pos1 == "top" && k) continue; var additional = !k ? "" : "-additional"; var fullpos = pos1+"-"+pos2+additional; for (var l=0; l<7; l++) { if (!this.checkIfWidgetExists(l, fullpos, widgets)) return [l, fullpos]; }; } } } return false; } this.checkIfWidgetExists = function(pos, corner, widgets) { if (!widgets) widgets = API.Storage.get("hotWidget"); for (var i in widgets) { if (widgets[i][0] == pos && widgets[i][1] == corner) return true; } return false; } this.getAddonStyle = function(id, icon) { return ` .icon.addon__custom_${id} { background: ${Engine.addonsPanel.createBackgroundString(icon)} !important; } `; } this.changeWidgetCss = function(widgets, custom) { //cache stuff if (!custom) addedWidgets2 = widgets; for (var id in widgets) { var widget = widgets[id]; if (widget.color || widget.css) { var $widget = document.getElementsByClassName((custom ? "addon__custom_" : "addon_")+widget.id)[0]; if (!$widget) continue; else $widget = $widget.parentElement; if (widget.color) { $widget.classList.remove("green"); $widget.classList.add(widget.color); } if (widget.css) { Object.assign($widget.style, widget.css); } } } } this.init = function() { addons.emmiter.once("game-load", this.addWidgetData); addons.emmiter.once("interface-load", ()=>{ this.changeWidgetCss(addedWidgets, true); var observer = new MutationObserver(this.onWidgetUpdate); for (var i=0; i<2; i++) { var pos1 = i ? "top" : "bottom"; for (var j=0; j<2; j++) { var pos2 = j ? "right" : "left"; observer.observe(document.querySelector("."+pos1+"-"+pos2+".main-buttons-container"), { childList: true }) } } }); } this.onWidgetUpdate = function(mutations, observer) { if (mutations.length > 1) { addons.emmiter.emit("widget-update"); //readd css to widgets as they are all reset if this code runs self.changeWidgetCss(addedWidgets, true); self.changeWidgetCss(addedWidgets2); }; } this.init(); })(this); this.addonDisplay = new (function(addons) { //TODO //zmienić pokazywanie ikonek i nazwy klas bo założenia się trochę zmieniły w trakcie robienia a nazwy zostały var self = this, list = [], movedToWindow = [], hidden = true, $wrapper, $singleWrapper, $scrollWrapper, $scrollContent, $title, currentDisplay = false; this.add = function(options) { if (hidden) { $wrapper.style["display"] = "block"; hidden = false; } var $element = document.createElement("div"); $element.classList.add("addonDisplay-single-display") if (options.html) { $element.innerHTML += options.html; } else if (options.element) { $element.appendChild(options.element); } var $shortcut = document.createElement("div"); if (!options.icon) { $shortcut.innerHTML = options.name.charAt(0); } else { $shortcut.innerHTML = ""; } $shortcut.addEventListener("click", () => { this.loadDisplay(options.id); }); $shortcut.addEventListener("contextmenu", e => { e.preventDefault(); this.moveDisplayToWindow(options.id); }); $shortcut.dataset["tip"] = options.name; $scrollContent.appendChild($shortcut); list.push({ $: $element, $short: $shortcut, id: options.id, name: options.name, wndStyle: options.wndStyle }) } this.moveDisplayToWindow = function(id) { var display = this.getDisplayById(id); display.$short.style["display"] = "none"; if (currentDisplay == display) { //display.$.remove(); //$title.innerHTML = ""; //currentDisplay = false; for (var i=0; i