-
Notifications
You must be signed in to change notification settings - Fork 3
/
operations.ts
54 lines (50 loc) · 1.66 KB
/
operations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { log } from "userscripter";
import { ALWAYS, DOMCONTENTLOADED } from "userscripter/run-time/environment";
import { Operation, operation } from "userscripter/run-time/operations";
import { P, Preferences } from "~src/preferences";
import { menuGenerator } from "~src/preferences-menu";
import * as SITE from "~src/site";
import T from "~src/text";
import U from "~src/userscript";
import insertFoobars from "./operations/foobars";
const OPERATIONS: ReadonlyArray<Operation<any>> = [
operation({
description: "change heading content",
condition: ALWAYS,
dependencies: { heading: SITE.SELECTOR_HEADING },
action: e => {
e.heading.textContent = T.heading;
},
}),
operation({
description: "insert foobars",
condition: () => Preferences.get(P.foobars._.insert),
dependencies: { mainDiv: SITE.SELECTOR_MAIN },
action: insertFoobars,
}),
operation({
description: "change title",
condition: ALWAYS,
action: () => {
document.title = document.title + T.title_suffix;
},
}),
operation({
description: "print console messages",
condition: ALWAYS,
action: () => {
log.log(T.messages.greeting(Preferences.get(P.username)));
log.log(T.messages.info(document.querySelectorAll("div").length));
},
}),
operation({
description: "insert preferences menu",
condition: ALWAYS,
action: () => {
const form = menuGenerator(P);
document.body.appendChild(form);
},
deferUntil: DOMCONTENTLOADED,
}),
];
export default OPERATIONS;