Skip to content
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

自動で完了済みにするかどうかの設定を追加 #61

Open
wants to merge 2 commits into
base: submission-detection
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
45 changes: 24 additions & 21 deletions src/content_script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,28 +125,31 @@ async function main() {

miniPandAReady();
updateIsReadFlag(mergedKadaiListNoMemo);

// 課題提出画面にいるなら、課題を完了済みとしてマークする
detectSubmission((info) => {
console.log('submission detected');
console.log(info);
// 設定がONのとき
if (CPsettings.detectSubmission) {
loadFromStorage("TSkadaiList")
.then((kadaiList: Array<Kadai>) => {
LOOP:
for (const kadai of kadaiList) {
if (kadai.lectureID == info.siteId) {
for (const kadaiEntry of kadai.kadaiEntries) {
if (kadaiEntry.kadaiID == info.assignmentId) {
kadaiEntry.isFinished = true;
break LOOP;
}
}
}
}
saveToStorage("TSkadaiList", kadaiList);
});
}
});
}
}

main();

// 課題提出画面にいるなら、課題を完了済みとしてマークする
detectSubmission(info => {
console.log('submission detected');
console.log(info);
loadFromStorage("TSkadaiList")
.then((kadaiList: Array<Kadai>) => {
LOOP:
for (const kadai of kadaiList) {
if (kadai.lectureID == info.siteId) {
for (const kadaiEntry of kadai.kadaiEntries) {
if (kadaiEntry.kadaiID == info.assignmentId) {
kadaiEntry.isFinished = true;
break LOOP;
}
}
}
}
saveToStorage("TSkadaiList", kadaiList);
});
});
1 change: 1 addition & 0 deletions src/minipanda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ async function createSettingsTab(): Promise<void> {
createSettingItem("課題キャッシュ時間 [秒]", CPsettings.kadaiCacheInterval ?? kadaiCacheInterval, "kadaiCacheInterval");
createSettingItem("クイズキャッシュ時間 [秒]", CPsettings.quizCacheInterval ?? quizCacheInterval, "quizCacheInterval");
createSettingItem("デバッグモード", CPsettings.makePandAGreatAgain ?? false, "makePandAGreatAgain", false);
createSettingItem("提出時に自動で完了済にする", CPsettings.detectSubmission ?? false, "detectSubmission");

createSettingItem("カラー① 締切24時間前", CPsettings.topColorDanger ?? "#f78989", "topColorDanger");
createSettingItem("カラー① 締切5日前", CPsettings.topColorWarning ?? "#fdd783", "topColorWarning");
Expand Down
2 changes: 2 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export class Settings {
quizCacheInterval?: number;
displayCheckedKadai?: boolean;
makePandAGreatAgain?: boolean;
detectSubmission?: boolean;
topColorDanger?: string;
topColorWarning?: string;
topColorSuccess?: string;
Expand All @@ -16,6 +17,7 @@ export class DefaultSettings extends Settings {
static quizCacheInterval = 600;
static displayCheckedKadai = true;
static makePandAGreatAgain = false;
static detectSubmission = false;
static topColorDanger = "#f78989";
static topColorWarning = "#fdd783";
static topColorSuccess = "#8bd48d";
Expand Down