Skip to content

Commit b4b5335

Browse files
committed
fix: was a joke before but now seriously fixed issue with persisting solved state
1 parent eb07a5e commit b4b5335

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
keepcode.zip
2-
bugs.md
2+
bugs.md
3+
TODO.md

content.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,18 @@ async function getProblemData() {
4545
function waitForContentAndStore() {
4646
const observer = new MutationObserver(async () => {
4747
const titleEl = document.querySelector("div");
48-
if (titleEl && titleEl.textContent.trim()) {
48+
if (titleEl?.textContent.trim()) {
4949
observer.disconnect();
5050
const data = await getProblemData();
5151
if (!data) return; // Don't store invalid/undefined problems
52-
// Preserve existing status and solvedAt if present
52+
// Only update non-status fields, always preserve status/solvedAt
5353
browser.storage.local.get(data.slug).then((existing) => {
5454
const prev = existing[data.slug] || {};
55-
if (prev.status === "Solved") {
56-
data.status = prev.status;
57-
data.solvedAt = prev.solvedAt;
58-
}
55+
// Always preserve status and solvedAt if they exist
56+
if (prev.status) data.status = prev.status;
57+
if (prev.solvedAt) data.solvedAt = prev.solvedAt;
5958
browser.storage.local.set({ [data.slug]: data }).then(() => {
60-
console.log("Saved to storage:", data);
59+
console.log("Saved to storage (non-status fields updated):", data);
6160
}).catch((err) => {
6261
console.error("Storage error:", err);
6362
});
@@ -73,7 +72,7 @@ function waitForContentAndStore() {
7372
function waitForSubmissionResult(slug) {
7473
const observer = new MutationObserver(() => {
7574
const resultEl = document.querySelector('span[data-e2e-locator="submission-result"]');
76-
if (resultEl && resultEl.textContent.includes("Accepted")) {
75+
if (resultEl?.textContent.includes("Accepted")) {
7776
console.log("✅ Accepted detected via submission result!");
7877

7978
browser.storage.local.get(slug).then((existing) => {

0 commit comments

Comments
 (0)