-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchecker.js
More file actions
36 lines (33 loc) · 1.2 KB
/
checker.js
File metadata and controls
36 lines (33 loc) · 1.2 KB
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
// eslint-disable-next-line no-unused-vars
function checkUnderscript(pluginName) {
const window = typeof unsafeWindow === 'object' ? unsafeWindow : globalThis;
if (window.underscript) return;
const key = 'underscript.required';
if (!sessionStorage.getItem(key)) {
sessionStorage.setItem(key, '1'); // Set instantly to prevent multiple alerts happening
const message = "Looks like you don't have UnderScript installed, or you deactivated it! In order for plugins to work, you need to have it up and running. Until then, the features of this userscript will simply not work. Thank you for your understanding.";
if (window.SimpleToast) {
SimpleToast({
title: 'Missing Requirements',
text: message,
footer: pluginName,
});
} else if (window.BootstrapDialog) {
BootstrapDialog.show({
title: 'Oh No!',
type: BootstrapDialog.TYPE_WARNING,
message,
buttons: [{
label: 'Proceed',
cssClass: 'btn-primary',
action(dialog) {
dialog.close();
},
}],
});
} else {
sessionStorage.removeItem(key);
}
}
throw new Error(`${pluginName}: UnderScript required`);
}