diff --git a/js/account/trade-valuation.js b/js/account/trade-valuation.js
new file mode 100644
index 0000000..ed90290
--- /dev/null
+++ b/js/account/trade-valuation.js
@@ -0,0 +1,106 @@
+var Settings;
+var Utilities;
+
+(async () => {
+ Utilities = await import(chrome.runtime.getURL('resources/utils.js'));
+ Utilities = Utilities.default;
+
+ chrome.storage.sync.get(['PolyPlus_Settings'], async function(result){
+ Settings = result.PolyPlus_Settings
+ if (
+ Settings.ValueListInfo &&
+ Settings.ValueListInfo.Enabled == true &&
+ Settings.ValueListInfo.TradeValuation == true
+ ) {
+ const ColumnLabels = [
+ "name",
+ "short",
+ "value",
+ "type",
+ "trend",
+ "demand",
+ "tags"
+ ]
+
+ const TagColors = {
+ "Projected": "warning",
+ "Hoarded": "success",
+ "Rare": "primary",
+ "Freaky": "danger"
+ }
+
+ /*
+ 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") {
+ const LinkValue = tableRow.cells[j].getElementsByTagName('a')[0]
+ if (LinkValue) {
+ rowData.id = LinkValue.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 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')
+
+ 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 ValueJSON = ExtractTableJSON(ValueListDocument.getElementsByTagName('table')[0])
+
+ for (let card of Array.from(document.querySelectorAll('.card:has(a[href^="/store"])'))) {
+ const ItemValuations = Array.from(card.querySelectorAll('a[href^="/store"]')).map((item) => ValueJSON.filter((x) => x.id == item.getAttribute('href').split('/')[2])[0]||null).filter((x)=>x!=null&&x.tags[0]!="")
+
+ if (ItemValuations.length > 0) {
+ /* this code is so bad I never want to look at it again */
+
+ const QuestionMarkTooltip = document.createElement('i')
+ QuestionMarkTooltip.classList = 'fa fa-question-circle'
+ QuestionMarkTooltip.setAttribute('data-bs-toggle', 'tooltip')
+ QuestionMarkTooltip.setAttribute('data-bs-html', 'true')
+ ItemValuations.map((item) => {console.log(item.tags)})
+ QuestionMarkTooltip.setAttribute('data-bs-title', ItemValuations.map((item, i) => `
+ ${item.name}
+ ${ item.tags.map((x) => `
+ ${x}
+ `).join('')}
+
+ `).join(''))
+ card.getElementsByClassName('card-header')[0].appendChild(QuestionMarkTooltip)
+ }
+ }
+
+ Utilities.InjectResource("registerTooltips")
+ }
+ });
+})();
\ No newline at end of file
diff --git a/js/background.js b/js/background.js
index 618b3d2..f4fe6a5 100755
--- a/js/background.js
+++ b/js/background.js
@@ -89,7 +89,11 @@ const DefaultSettings = {
LeaderboardsOn: true
},
CollectibleInventoryCatOn: true,
- ShowValueListDataOn: true,
+ ValueListInfo: {
+ Enabled: true,
+ ItemValuation: true,
+ TradeValuation: true
+ },
ImprovedAchievements: {
Enabled: true,
ProgressBarOn: true,
diff --git a/js/store/item-view.js b/js/store/item-view.js
index 46348e3..d347f2f 100755
--- a/js/store/item-view.js
+++ b/js/store/item-view.js
@@ -56,7 +56,11 @@ var Utilities;
HoardersList(parseInt(Settings.HoardersList.MinCopies), Settings.HoardersList.AvatarsEnabled);
}
- if (Settings.ShowValueListDataOn && Settings.ShowValueListDataOn === true) {
+ if (
+ Settings.ValueListInfo &&
+ Settings.ValueListInfo.Enabled == true &&
+ Settings.ValueListInfo.ItemValuation == true
+ ) {
ValueListData()
}
}
diff --git a/manifest.json b/manifest.json
index 94420fb..cc8f1e3 100644
--- a/manifest.json
+++ b/manifest.json
@@ -131,6 +131,11 @@
{
"matches": ["https://polytoria.com/u/**"],
"js": ["/js/the-great-divide.js"]
+ },
+
+ {
+ "matches": ["https://polytoria.com/trade/view/**"],
+ "js": ["/js/account/trade-valuation.js"]
}
],
"background": {
diff --git a/resources/utils.js b/resources/utils.js
index e15e7e6..c8e1337 100644
--- a/resources/utils.js
+++ b/resources/utils.js
@@ -109,7 +109,11 @@ export default {
LeaderboardsOn: true
},
CollectibleInventoryCatOn: true,
- ShowValueListDataOn: true,
+ ValueListInfo: {
+ Enabled: true,
+ ItemValuation: true,
+ TradeValuation: true
+ },
ImprovedAchievements: {
Enabled: true,
ProgressBarOn: true,
diff --git a/settings.html b/settings.html
index aeec78f..cc54389 100755
--- a/settings.html
+++ b/settings.html
@@ -697,7 +697,7 @@
Sort a player's inventory by all of their limited-edition collectibles!
-