-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Add hourly periodic cloud settings sync #963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
7f7f08e
692f67f
ef9d428
733ecf7
2b5fb37
e654ffa
39b1621
3c7f746
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
@@ -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); | ||
| if (key === "Theme") themeChanged = true; | ||
| } | ||
| } | ||
| if (themeChanged) initTheme(); | ||
| } | ||
| SyncSettingsToCloud(); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| unsafeWindow.GetContestProblemList = async function(RefreshList) { | ||
| try { | ||
| const contestReq = await fetch("https://www.xmoj.tech/contest.php?cid=" + SearchParams.get("cid")); | ||
|
|
@@ -917,6 +939,7 @@ let initTheme = () => { | |
| } | ||
| }; | ||
| initTheme(); | ||
| setInterval(PeriodicCloudSync, 60 * 60 * 1000); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The hourly timer is anchored to page-load time ( Useful? React with 👍 / 👎. |
||
|
|
||
|
|
||
| class NavbarStyler { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.