Last active
December 4, 2025 16:32
-
-
Save walkeralencar/68c967fd3b5e36ab52eff3cdac2fa30e to your computer and use it in GitHub Desktop.
Improve informations from albiononline2d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Improve informations from albiononline2d | |
| // Load any page, open console, and use the code. | |
| // Author: Walker de Alencar <walkeralencar@gmail.com> | |
| /* Works only for journals | |
| config.itemsForMarketData = config.itemsForMarketData.split(',') | |
| config.itemsForMarketData.forEach(function(item,key){ | |
| if (!item.includes('_FULL')) { | |
| $("#" + item).prop('id',item + '_FULL'); | |
| config.itemsForMarketData[key] = item + '_FULL'; | |
| } | |
| }); | |
| config.itemsForMarketData = config.itemsForMarketData.join(','); | |
| /* JournalsEnd */ | |
| // ===== Função para calcular tempo ===== | |
| function timeAgo(dateString) { | |
| const now = new Date(); | |
| const date = new Date(dateString+'Z'); | |
| const diffMs = now - date; | |
| const seconds = Math.floor(diffMs / 1000); | |
| const minutes = Math.floor(seconds / 60); | |
| const hours = Math.floor(minutes / 60); | |
| const days = Math.floor(hours / 24); | |
| console.log(`Time ago for ${dateString}: ${days}d ${hours}h ${minutes}m ${seconds}s`); | |
| let text = ""; | |
| if (seconds < 60) text = `${seconds}s`; | |
| else if (minutes < 60) text = `${minutes}m`; | |
| else if (hours < 24) text = `${hours}h`; | |
| else text = `${days}d`; | |
| const isOld = hours >= 8; // dados velhos se > 2 horas | |
| return { text, isOld }; | |
| } | |
| // ===== CONFIG VISUAL E CIDADES ===== | |
| if ($('style#city-colors').length == 0) { | |
| console.log("[AOD2-Prices] Configs done."); | |
| $('head').append($('<style id="city-colors">.brecilien{background-color:#7564b9}.caerleon{background-color:#1e0e02}.thetford{background-color:#5a2d5a}.fortsterling{background-color:#fff5e6}.lymhurst{background-color:#4d570f}.bridgewatch{background-color:#d26923}.martlock{background-color:#556e87}.blackmarket{background-color:#000;color:#fff}.data-old{border:1px dashed red !important;}</style>')); | |
| $(".container.pb-5").css('max-width', $(window).width()).css('margin', '0px'); | |
| $(".col-xl-4").removeClass("col-xl-4").addClass("col-xl-3"); | |
| $(".sidebar").remove(); | |
| var cityMapping = { | |
| 'Brecilien': 'brecilien', | |
| 'Caerleon': 'caerleon', | |
| 'Thetford': 'thetford', | |
| 'Fort Sterling': 'fortsterling', | |
| 'Lymhurst': 'lymhurst', | |
| 'Bridgewatch': 'bridgewatch', | |
| 'Martlock': 'martlock', | |
| 'Black Market': 'blackmarket' | |
| }; | |
| var locations = 'Caerleon,Bridgewatch,Thetford,Fort%20Sterling,Lymhurst,Martlock,Black%20Market'; | |
| } | |
| // ===== BUSCA DE PREÇOS ===== | |
| var tData = []; | |
| console.log('https://www.albion-online-data.com/api/v2/stats/prices/' + config.itemsForMarketData + '?locations=' + locations); | |
| $.get('https://www.albion-online-data.com/api/v2/stats/prices/' + config.itemsForMarketData + '?qualities=1&locations=' + locations, function (response) { | |
| var item_id = ''; | |
| response.forEach(function (cityItem) { | |
| // nova mudança de item | |
| if (cityItem.item_id != item_id) { | |
| $('#' + $.escapeSelector(cityItem.item_id) + " span").remove(); | |
| $('#' + $.escapeSelector(cityItem.item_id)) | |
| .html($('#' + $.escapeSelector(cityItem.item_id)).html().replace(/ /gi, '')); | |
| if (item_id !== '' && tData[item_id] !== undefined) { | |
| tData[item_id].sort(function (a, b) { | |
| return a.sell - b.sell; | |
| }); | |
| $("#" + $.escapeSelector(item_id) + ' [title^="' + tData[item_id][0].city + '"]').addClass("border rounded-circle"); | |
| $("#" + $.escapeSelector(item_id) + ' [title^="' + tData[item_id].pop().city + '"]').addClass("border"); | |
| } | |
| item_id = cityItem.item_id; | |
| } | |
| if (cityItem.buy_price_max == 0 || cityItem.sell_price_min == 0) return; | |
| var buyInfo = timeAgo(cityItem.buy_price_max_date); | |
| var sellInfo = timeAgo(cityItem.sell_price_min_date); | |
| var tooltip = cityItem.city + | |
| "\nBuy: " + buyInfo.text + | |
| "\nSell: " + sellInfo.text; | |
| var extraClass = ""; | |
| if (buyInfo.isOld || sellInfo.isOld) { | |
| extraClass = " data-old"; | |
| } | |
| var formattedBuyPrice = new Intl.NumberFormat().format(cityItem.buy_price_max); | |
| var formattedSellPrice = new Intl.NumberFormat().format(cityItem.sell_price_min); | |
| var node = '<span class="badge :class:extra" title=":tooltip">:buy | :sell</span> ' | |
| .replace(':class', cityMapping[cityItem.city]) | |
| .replace(':extra', extraClass) | |
| .replace(':tooltip', tooltip) | |
| .replace(':buy', formattedBuyPrice) | |
| .replace(':sell', formattedSellPrice); | |
| if (tData[item_id] === undefined) { | |
| tData[item_id] = []; | |
| } | |
| tData[item_id].push({ | |
| city: cityItem.city, | |
| buy: cityItem.buy_price_max, | |
| sell: cityItem.sell_price_min | |
| }); | |
| $('#' + $.escapeSelector(cityItem.item_id)).append(node); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment