From 352791710b40450679165458943b5d3d2bfcb3d0 Mon Sep 17 00:00:00 2001 From: Kobe De Peuter Date: Mon, 6 Jan 2025 19:42:15 +0100 Subject: [PATCH] Hide the recycle message on the item page. --- extension/changelog.json | 2 +- extension/manifest.json | 3 +- extension/pages/settings/settings.html | 4 ++ .../ttHideRecycleMessage.js | 44 +++++++++++++++++++ extension/scripts/global/globalData.js | 1 + 5 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 extension/scripts/features/hide-recycle-message/ttHideRecycleMessage.js diff --git a/extension/changelog.json b/extension/changelog.json index 7c38a7f21..ecd6d625f 100644 --- a/extension/changelog.json +++ b/extension/changelog.json @@ -4,7 +4,7 @@ "title": "Beta", "date": false, "logs": { - "features": [], + "features": [{ "message": "Hide the recycle message on the item page.", "contributor": "DeKleineKobini" }], "fixes": [ { "message": "Correctly count the supply pack value.", "contributor": "DeKleineKobini" }, { "message": "Avoid an error on the item market when switching categories.", "contributor": "DeKleineKobini" }, diff --git a/extension/manifest.json b/extension/manifest.json index 06e910938..5205f6c6f 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -517,7 +517,8 @@ "scripts/features/no-confirm/ttItemNoConfirm.js", "scripts/features/energy-warning/ttEnergyWarning.js", "scripts/features/medical-life/ttMedicalLife.js", - "scripts/features/opened-supply-pack-value/ttOpenedSupplyPackValue.js" + "scripts/features/opened-supply-pack-value/ttOpenedSupplyPackValue.js", + "scripts/features/hide-recycle-message/ttHideRecycleMessage.js" ], "run_at": "document_end" }, diff --git a/extension/pages/settings/settings.html b/extension/pages/settings/settings.html index e9d99a536..357ab6c1c 100644 --- a/extension/pages/settings/settings.html +++ b/extension/pages/settings/settings.html @@ -1083,6 +1083,10 @@

+
+ + +
Museum Sets
diff --git a/extension/scripts/features/hide-recycle-message/ttHideRecycleMessage.js b/extension/scripts/features/hide-recycle-message/ttHideRecycleMessage.js new file mode 100644 index 000000000..26ef2d581 --- /dev/null +++ b/extension/scripts/features/hide-recycle-message/ttHideRecycleMessage.js @@ -0,0 +1,44 @@ +"use strict"; + +(async () => { + if (!getPageStatus().access) return; + + featureManager.registerFeature( + "Hide Recycle Message", + "items", + () => settings.pages.items.hideRecycleMessage, + null, + hideMessage, + showMessage, + { + storage: ["settings.pages.items.hideRecycleMessage"], + }, + null + ); + + function hideMessage() { + const recycleMessageElement = document.evaluate( + "//*[contains(@class, 'info-msg-cont')][.//*[contains(text(), 'clear up your inventory')]]", + document, + null, + XPathResult.FIRST_ORDERED_NODE_TYPE, + null + ).singleNodeValue; + if (!recycleMessageElement) return; + + const delimiter = recycleMessageElement.previousElementSibling; + + console.log("DKK warning", recycleMessageElement); + + recycleMessageElement.dataset.type = "recycle-message"; + recycleMessageElement.classList.add("tt-hidden"); + delimiter.dataset.type = "recycle-message"; + delimiter.classList.add("tt-hidden"); + } + + function showMessage() { + document.findAll(".tt-hidden[data-type='recycle-message']").forEach((hidden) => { + hidden.classList.remove("tt-hidden"); + }); + } +})(); diff --git a/extension/scripts/global/globalData.js b/extension/scripts/global/globalData.js index 2663c5b08..a1901c7d0 100644 --- a/extension/scripts/global/globalData.js +++ b/extension/scripts/global/globalData.js @@ -497,6 +497,7 @@ const DEFAULT_STORAGE = { energyWarning: new DefaultSetting({ type: "boolean", defaultValue: true }), medicalLife: new DefaultSetting({ type: "boolean", defaultValue: true }), openedSupplyPackValue: new DefaultSetting({ type: "boolean", defaultValue: true }), + hideRecycleMessage: new DefaultSetting({ type: "boolean", defaultValue: false }), }, crimes: { quickCrimes: new DefaultSetting({ type: "boolean", defaultValue: true }),