Skip to content

Commit

Permalink
Hide the recycle message on the item page.
Browse files Browse the repository at this point in the history
  • Loading branch information
DeKleineKobini committed Jan 6, 2025
1 parent d411d61 commit 3527917
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extension/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
3 changes: 2 additions & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 4 additions & 0 deletions extension/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@ <h2>
<input id="items-openedSupplyPackValue" type="checkbox" />
<label for="items-openedSupplyPackValue">Show the total value of items obtained when opening supply pack.</label>
</div>
<div class="option">
<input id="items-hideRecycleMessage" type="checkbox" />
<label for="items-hideRecycleMessage">Hide the recycle message.</label>
</div>

<div class="header">Museum Sets</div>
<div class="option">
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
});
}
})();
1 change: 1 addition & 0 deletions extension/scripts/global/globalData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
Expand Down

0 comments on commit 3527917

Please sign in to comment.