Skip to content

Commit 34079f4

Browse files
Check whether your data is corrupted on the about page. (#834)
1 parent c835763 commit 34079f4

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

extension/changelog.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
{ "message": "Completely migrate over to API v2 for personalstats.", "contributor": "DeKleineKobini" },
2828
{ "message": "Adjust achievements for crimes 2.", "contributor": "DeKleineKobini" },
2929
{ "message": "Include some missing achievements like hospitals and jail visits and special ammo.", "contributor": "DeKleineKobini" },
30-
{ "message": "Improve page detection on 'loader.php'.", "contributor": "DeKleineKobini" }
30+
{ "message": "Improve page detection on 'loader.php'.", "contributor": "DeKleineKobini" },
31+
{ "message": "Check whether your data is corrupted on the about page.", "contributor": "DeKleineKobini" }
3132
],
3233
"removed": []
3334
}

extension/pages/settings/about.css

+8
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ body.dark #about a {
7070
border: none;
7171
border-bottom: 1px solid #aaa;
7272
}
73+
74+
.corruption-okay {
75+
color: greenyellow;
76+
}
77+
78+
.corruption-error {
79+
color: red;
80+
}

extension/pages/settings/settings.html

+18
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,24 @@ <h2>About</h2>
20072007
<span class="note">Estimation of the stored data, not the extension files.</span>
20082008
</p>
20092009
</section>
2010+
<section>
2011+
<p class="mt10">
2012+
<strong>Userdata:</strong>
2013+
<span id="userdata-corruption">checking...</span>
2014+
</p>
2015+
<p>
2016+
<strong>Torndata:</strong>
2017+
<span id="torndata-corruption">checking...</span>
2018+
</p>
2019+
<p>
2020+
<strong>Stockdata:</strong>
2021+
<span id="stockdata-corruption">checking...</span>
2022+
</p>
2023+
<p>
2024+
<strong>Factiondata:</strong>
2025+
<span id="factiondata-corruption">checking...</span>
2026+
</p>
2027+
</section>
20102028
<section>
20112029
<p>
20122030
Our source code is available on <a href="https://github.com/Mephiles/torntools_extension" target="_blank">Github</a> and licenced under the

extension/pages/settings/settings.js

+22
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,12 @@ function setupAbout() {
18251825
// version
18261826
about.find(".version").textContent = chrome.runtime.getManifest().version;
18271827

1828+
// data corruption
1829+
showCorruption("userdata-corruption", () => typeof userdata === "object" && Object.keys(userdata).length > 5);
1830+
showCorruption("torndata-corruption", () => typeof torndata === "object" && typeof torndata.items === "object" && Object.keys(torndata.items).length > 5);
1831+
showCorruption("stockdata-corruption", () => typeof stockdata === "object" && Object.keys(stockdata).length > 5);
1832+
showCorruption("factiondata-corruption", () => typeof factiondata === "object" && typeof factiondata.access === "string");
1833+
18281834
// disk space
18291835
ttStorage.getSize().then((size) => (about.find(".disk-space").textContent = formatBytes(size)));
18301836

@@ -1872,6 +1878,22 @@ function setupAbout() {
18721878
ourTeam.appendChild(card);
18731879
}
18741880
}
1881+
1882+
function showCorruption(id, checkFunction) {
1883+
const element = about.find(`#${id}`);
1884+
if (!element) return;
1885+
1886+
const status = checkFunction();
1887+
1888+
element.classList.remove("corruption-okay", "corruption-error");
1889+
if (status) {
1890+
element.textContent = "likely okay";
1891+
element.classList.add("corruption-okay");
1892+
} else {
1893+
element.textContent = "possibly corrupted";
1894+
element.classList.add("corruption-error");
1895+
}
1896+
}
18751897
}
18761898

18771899
function formatBytes(bytes, options = {}) {

0 commit comments

Comments
 (0)