forked from quoid/userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.svelte
More file actions
148 lines (132 loc) · 2.9 KB
/
Copy pathApp.svelte
File metadata and controls
148 lines (132 loc) · 2.9 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<script>
import icon from "./img/icon.png";
import logo from "./img/logo.svg?raw";
let version = "v0.0.0";
let build = "(0)";
let directory = "init";
window.APP = {
show: () => {},
printVersion: (v, b) => {
version = v;
build = b;
},
printDirectory: (d) => {
directory = d;
},
};
function changeDirectory() {
window.webkit?.messageHandlers.controller.postMessage("CHANGE_DIRECTORY");
}
function openDirectory() {
window.webkit?.messageHandlers.controller.postMessage("OPEN_DIRECTORY");
}
</script>
<main>
<img class="icon" src={icon} alt="Userscripts App Icon" draggable="false" />
<div class="logo">
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
{@html logo}
<span>
{#if import.meta.env.GIT_TAG && import.meta.env.GIT_COMMIT}
<a
href="https://github.com/quoid/userscripts/releases/tag/{import.meta
.env.GIT_TAG}"
>
{import.meta.env.GIT_TAG}
</a>
(<a
href="https://github.com/quoid/userscripts/commit/{import.meta.env
.GIT_COMMIT}"
>
{import.meta.env.GIT_COMMIT.slice(0, 7)}
</a>)
{:else}
<span>{version}</span>
<span>{build}</span>
{/if}
</span>
</div>
<p>
You can turn on the Userscripts iOS Safari extension in Settings.
<a
href="https://github.com/quoid/userscripts/blob/{import.meta.env
.GIT_TAG ?? 'main'}/README.md"
>
Read the docs.
</a>
</p>
<button id="change-directory" on:click={changeDirectory}>
Change Userscripts Directory
</button>
<div class="current">CURRENT DIRECTORY:</div>
<div id="directory">
<button class="link" on:click={openDirectory}>{directory}</button>
</div>
</main>
<style>
main {
align-items: center;
display: flex;
flex-direction: column;
height: 100%;
justify-content: center;
padding: 0 1rem;
text-align: center;
-webkit-touch-callout: none;
user-select: none;
}
a {
color: var(--color-blue);
}
.icon {
height: 8rem;
width: 8rem;
}
.logo {
align-items: flex-end;
display: flex;
margin: 1rem 0;
}
.logo :global(svg) {
height: 1.5rem;
}
.logo > span {
text-align: left;
min-width: 3.5rem;
margin-left: 0.5rem;
}
.logo span,
.current {
color: var(--text-color-disabled);
font: var(--text-small);
font-weight: bold;
letter-spacing: var(--letter-spacing-small);
}
button#change-directory {
background-color: var(--color-blue);
border: none;
border-radius: var(--border-radius);
color: var(--color-bg-secondary);
font: var(--text-default);
font-weight: 500;
letter-spacing: var(--letter-spacing-default);
margin: 2rem 0 1rem;
padding: 0.5rem 1rem;
}
button#change-directory:active {
background-color: #6296c7;
}
#directory {
color: var(--editor-default);
font-family: var(--editor-font);
font-size: 0.875rem;
font-weight: 400;
word-break: break-all;
min-height: 7rem;
max-height: 10rem;
}
#directory button {
color: inherit;
text-decoration: none;
}
</style>