-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0667ddf
commit 315dd5e
Showing
3 changed files
with
42 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import env from '../env/env'; | ||
|
||
export function toggleCoachMode() { | ||
let data = new URLSearchParams(); | ||
data.append("action", "toggleGymContestsManagerEnabled"); | ||
data.append("csrf_token",env.global.Codeforces.getCsrfToken()); | ||
data.append("_tta", env.global.Codeforces.tta()); | ||
|
||
return fetch("/gyms", { | ||
method: "POST", | ||
body: data, | ||
}) | ||
.then(res => res.text()) | ||
.then(html => { | ||
let doc = new DOMParser().parseFromString(html, "text/html"); | ||
let btn = doc.querySelector(".toggleGymContestsManagerEnabled input[type=submit]"); | ||
let status = btn && btn.value.startsWith("Disable") ? "enabled" : "disabled"; | ||
|
||
env.global.Codeforces.reloadAndShowMessage(`Coach mode is now ${status}`); | ||
}) | ||
.catch(err => console.error("Codeforces++ couldn't toggle coach mode: ", err)); | ||
} |