Skip to content

Commit bdde865

Browse files
committed
feat: added prepswift auto mark as complete
1 parent 834a894 commit bdde865

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

.changeset/silly-rice-smoke.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gregmat-buddy": patch
3+
---
4+
5+
added support for marking lecture complete when video ends

src/entrypoints/options/App.svelte

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
tooltip: "Shows total time and lectures completed",
4646
checked: config.prepswiftStats,
4747
},
48+
{
49+
id: "prepswiftAutoComplete",
50+
text: "Auto mark lecture on completion",
51+
tooltip: "Marks lecture as completed when video ends",
52+
checked: config.prepswiftAutoComplete,
53+
},
4854
],
4955
} as const;
5056
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { VIMEO_SELECTOR } from "@/constants";
2+
import Player from "@vimeo/player";
3+
import { config as config_store } from "@/utils/storage";
4+
5+
export async function main() {
6+
register();
7+
window.addEventListener("vimeoAdded", register);
8+
}
9+
10+
async function register() {
11+
const config = await config_store.getValue();
12+
if (!config.prepswiftAutoComplete) return;
13+
14+
const iframe = document.querySelector(VIMEO_SELECTOR);
15+
16+
if (!iframe) return;
17+
18+
const player = new Player(iframe as HTMLIFrameElement);
19+
20+
player.on("ended", () => {
21+
const tickbox = document.querySelector("svg[data-icon='square']");
22+
23+
if (!tickbox) return;
24+
25+
tickbox.parentElement?.click();
26+
});
27+
}

src/entrypoints/prepswift.content/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { waitForElement, registerUrl } from "@/utils";
22
import { config as config_store } from "@/utils/storage";
3+
import { main as autocomplete } from "./autocomplete";
34

45
export default defineContentScript({
56
matches: ["*://*.prepswift.com/*"],
6-
runAt: "document_idle",
77
main() {
8+
autocomplete();
89
registerUrl("gre-quant", main);
910
registerUrl("gre-verbal", main);
1011
registerUrl("gre-writing", main);

src/utils/storage.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type ConfigType = {
1212
playbackRate: boolean;
1313
vocabMountain: boolean;
1414
prepswiftStats: boolean;
15+
prepswiftAutoComplete: boolean;
1516
};
1617

1718
export const config = storage.defineItem<ConfigType>("local:config", {
@@ -20,6 +21,7 @@ export const config = storage.defineItem<ConfigType>("local:config", {
2021
playbackRate: true,
2122
vocabMountain: true,
2223
prepswiftStats: true,
24+
prepswiftAutoComplete: true,
2325
},
2426
version: 1,
2527
});

0 commit comments

Comments
 (0)