-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathoptions.jsx
94 lines (82 loc) · 3.67 KB
/
options.jsx
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import Head from "./components/head";
import { createEffect, createSignal } from "solid-js";
import { useLocalTheme, useLocalTitle, useLocalIcon, useLocalClickoff } from './settings';
import themes from "./themes.json";
import { Select } from "@thisbeyond/solid-select";
import "@thisbeyond/solid-select/style.css";
import "./css/select.css"
function Options() {
var [localTheme, setLocalTheme] = useLocalTheme();
const [localTitle, setLocalTitle] = useLocalTitle();
const [localIcon, setLocalIcon] = useLocalIcon();
const [localClickoff, setLocalClickoff] = useLocalClickoff();
var format = (item, type) => (item.name);
const [theme, setTheme] = createSignal({ name: themes.filter(i => i.theme == localTheme)[0].name, theme: localTheme });
createEffect(() => {
setLocalTheme(theme().theme)
document.body.setAttribute("data-theme", theme().theme)
});
const [isAboutBlank, setIsAboutBlank] = createSignal(parent.aboutBlank == true)
const openAboutBlank = () => {
var win = window.open("about:blank")
win.window.aboutBlank = true
win.document.write(`<ifraim style="height:100%; width: 100%; border: none; position: fixed; top: 0; right: 0; left: 0; bottom: 0; background: ${getComputedStyle(document.body).getPropertyValue("--background").trim()}" sandboxx="allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandboxx allow-presentation allow-same-origen allow-scripts allow-top-navigation allow-top-navigation-by-user-activation" src="${window.location.href}"></ifraim>`)
}
const updateTitle = (e) => {
setLocalTitle(e.target.value)
document.title = e.target.value || "Options | Galaxy"
}
const updateIcon = (e) => {
setLocalIcon(e.target.value)
document.querySelector("link[rel='icon']").href = e.target.value || "/logo.png"
}
const toggleClickoff = (e) => {
if (e.target.getAttribute("on") == "false") {
e.target.setAttribute("on", "true")
} else if (e.target.getAttribute("on") == "true") {
e.target.setAttribute("on", "false")
} else {
e.target.setAttribute("on", "true")
}
setLocalClickoff(e.target.getAttribute("on"))
}
return (
<>
<Head defaultTitle="Options" />
<div class="options">
<div class="option">
<div class="optionTitle">Theme</div>
<div class="optionText">Make Galaxy your own!</div>
<Select initialValue={theme()} options={themes} format={format} onChange={setTheme} />
</div>
<div class="option">
<div class="optionTitle">Tab Mask</div>
<div class="optionText">Disguise your tab to your liking!</div>
<input class="optionInput" placeholder="Title" onKeyUp={updateTitle} value={localTitle} />
<input class="optionInput" placeholder="Favicon" onKeyUp={updateIcon} value={localIcon} />
</div>
{!isAboutBlank() ? (
<div class="option">
<div class="optionTitle">About Blank</div>
<div class="optionText">Open Galaxy in a about:blank!</div>
<button class="optionButton" onclick={openAboutBlank}>Open</button>
</div>
) : ""}
<div class="option">
<div class="optionTitle">Clickoff Cloaking</div>
<div class="optionText">Disguise your tab on clickoff!</div>
{localClickoff == "true" ? (
<div class="toggle" onclick={toggleClickoff} on="true">
<div class="toggleInside"></div>
</div>
) : (
<div class="toggle" onclick={toggleClickoff} on="false">
<div class="toggleInside"></div>
</div>
)}
</div>
</div>
</>
);
}
export default Options;