diff --git a/js/background.js b/js/background.js index b6c1f7a..3e688d1 100755 --- a/js/background.js +++ b/js/background.js @@ -88,7 +88,8 @@ const DefaultSettings = { UserStatsOn: true, LeaderboardsOn: true }, - CollectibleInventoryCatOn: true + CollectibleInventoryCatOn: true, + ShowValueListDataOn: true } // ON EXTENSION INSTALL / RELOAD diff --git a/js/store/item-view.js b/js/store/item-view.js index 80e31c8..f15dc37 100755 --- a/js/store/item-view.js +++ b/js/store/item-view.js @@ -55,7 +55,13 @@ var Utilities; if (Settings.HoardersList && Settings.HoardersList.Enabled === true) { HoardersList(parseInt(Settings.HoardersList.MinCopies), Settings.HoardersList.AvatarsEnabled); } - } else if (Settings.ItemOwnerCheckOn === true && document.getElementById('timer') && /\d/.test(document.getElementById('timer').innerText)) { + + if (Settings.ShowValueListDataOn && Settings.ShowValueListDataOn === true) { + ValueListData() + } + } + + if (Settings.ItemOwnerCheckOn === true && ((document.getElementById('timer') !== null && /\d/.test(document.getElementById('timer').innerText) || document.getElementById('resellers') !== null))) { CheckOwner(); } @@ -728,3 +734,139 @@ function CheckOwner() { } }); } + +async function ValueListData() { + let Tabs = document.getElementById('store-tabs'); + + const ValueSection = document.createElement('div') + ValueSection.classList = 'mb-3' + ValueSection.innerHTML = ` +
+ Valuation (based off LOVE) +
+
+
+ + Loading... + + +
+
+ ` + Tabs.parentElement.insertBefore(ValueSection, Tabs) + + const ValueCard = document.getElementById('p+valuation_card').children[0] + + const ColumnLabels = [ + "name", + "short", + "value", + "type", + "trend", + "demand", + "tags" + ] + + const TagColors = { + "Projected": "warning", + "Hoarded": "success", + "Rare": "primary", + "Freaky": "danger" + } + + const ValueListDocument = new DOMParser().parseFromString(await (await fetch('https://docs.google.com/feeds/download/documents/Export?exportFormat=html&format=html&id=1W7JN74MU-9Dbd-9xNnjxE18hQVBPXWuwjK5DGSnuQR4')).text(), 'text/html') + + /* + Table to JSON function (slightly modified for my use-case) + https://stackoverflow.com/questions/9927126/how-to-convert-the-following-table-to-json-with-javascript#answer-60196347 + */ + const ExtractTableJSON = function(table) { + var data = []; + for (var i = 1; i < table.rows.length; i++) { + var tableRow = table.rows[i]; + var rowData = { + tags: [] + }; + for (var j = 0; j < tableRow.cells.length; j++) { + let Value = tableRow.cells[j].children[0].children[0].innerText; + if (ColumnLabels[j] === "name") { + rowData.id = tableRow.cells[j].children[0].children[0].children[0].href.split('https://www.google.com/url?q=')[1].split('&')[0].split('/')[4] + } + if (ColumnLabels[j] === "tags") { + Array.from(tableRow.cells[j].children).forEach(tag => { + /* + The regex for the emoji character codes replacement was made by AI, such a time saver lol + */ + rowData.tags.push(tag.children[0].innerHTML.replace(/\s/g,'').replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, '')) + }) + } else { + rowData[ColumnLabels[j]] = Value + } + } + data.push(rowData); + } + return data; + } + + const GetTagColor = function(label) { + if (TagColors[label] !== undefined) { + return TagColors[label] + } else if (TagColors[label.substring(1)] !== undefined) { + return TagColors[label.substring(1)] + } else { + return 'dark' + } + } + + const ValueDetails = ExtractTableJSON(ValueListDocument.getElementsByTagName('table')[0]).filter((x) => x.id === ItemID)[0] + + if (ValueDetails !== undefined) { + ValueCard.innerHTML = ` +
+ + + Value + + + ${ValueDetails.value} + +
+
+ + % + Trend + + + ${ValueDetails.trend} + +
+
+ + + Valuation Type + + + ${ValueDetails.type} + +
+
+ + + Shorthand + + + ${ValueDetails.short} + +
+
+ ${ ValueDetails.tags.map((x) => ` + ${x} + `).join('')} +
+ ` + } else { + ValueCard.innerHTML = ` + There is no evaluation for this item at this time. + ` + } +} \ No newline at end of file diff --git a/resources/utils.js b/resources/utils.js index 2b67bb4..a7b1144 100644 --- a/resources/utils.js +++ b/resources/utils.js @@ -108,7 +108,8 @@ export default { UserStatsOn: true, LeaderboardsOn: true }, - CollectibleInventoryCatOn: true + CollectibleInventoryCatOn: true, + ShowValueListDataOn: true }, Limits: { PinnedGames: 10, diff --git a/settings.html b/settings.html index e5b9580..9116336 100755 --- a/settings.html +++ b/settings.html @@ -714,6 +714,22 @@ Sort a player's inventory by all of their limited-edition collectibles! +
+   + + "List of Values Everlast" Integration + +
+ +
+
+ + Quickly see a collectible's evaluation by the community-trusted "List-of-Values Everlast" guild! + + + * This feature will be expanded to allow you to pick from a list of value lists (list-inception), if any prominent value lists pop-up in the future! + +