Skip to content
23 changes: 23 additions & 0 deletions XMOJ.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,28 @@ let SyncSettingsToCloud = (CallBack) => {
});
};

let PeriodicCloudSync = () => {
if (!CurrentUsername || !UtilityEnabled("CloudSync")) return;
RequestAPI("GetUserSettings", {}, (Response) => {
if (Response.Success) {
const cloudSettings = (Response.Data && Response.Data.Settings) || {};
if (Object.keys(cloudSettings).length > 0) {
let themeChanged = false;
for (let key in cloudSettings) {
const rawValue = String(cloudSettings[key]);
const localKey = "UserScript-Setting-" + key;
if (localStorage.getItem(localKey) !== rawValue) {
localStorage.setItem(localKey, rawValue);
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
if (key === "Theme") themeChanged = true;
}
}
if (themeChanged) initTheme();
}
}
SyncSettingsToCloud();
Comment thread
PythonSmall-Q marked this conversation as resolved.
Outdated
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
});
};

unsafeWindow.GetContestProblemList = async function(RefreshList) {
try {
const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid"));
Expand Down Expand Up @@ -917,6 +939,7 @@ let initTheme = () => {
}
};
initTheme();
if (UtilityEnabled("CloudSync")) setInterval(PeriodicCloudSync, 60 * 60 * 1000);
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
Comment thread
PythonSmall-Q marked this conversation as resolved.
Outdated
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated


class NavbarStyler {
Expand Down
Loading