Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3530,6 +3530,17 @@
}
],
"Notes": "No release notes were provided for this release."
},
"3.4.2": {
"UpdateDate": 1774704899385,
"Prerelease": true,
"UpdateContents": [
{
"PR": 963,
"Description": "feat: Add hourly periodic cloud settings sync"
}
],
"Notes": "Add hourly automatic cloud settings sync. Every hour, if CloudSync is enabled, settings are downloaded from the cloud and applied locally, then local settings are uploaded to the cloud. This keeps settings in sync across devices without requiring a visit to the settings page."
}
}
}
25 changes: 24 additions & 1 deletion XMOJ.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name XMOJ
// @version 3.4.1
// @version 3.4.2
// @description XMOJ增强脚本
// @author @XMOJ-Script-dev, @langningchen and the community
// @namespace https://github/langningchen
Expand Down 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmoj-script",
"version": "3.4.1",
"version": "3.4.2",
"description": "an improvement script for xmoj.tech",
"main": "AddonScript.js",
"scripts": {
Expand Down
Loading