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
173 lines (154 loc) · 3.69 KB
/
Copy pathApp.svelte
File metadata and controls
173 lines (154 loc) · 3.69 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<script>
import icon from "./img/icon.png";
import logo from "./img/logo.svg?raw";
const baseUrl = "https://github.com/quoid/userscripts";
const webkit = window.webkit.messageHandlers.controller;
let directory = "init";
window.webapp = {
updateDirectory: (newDir) => (directory = newDir),
};
async function initialize() {
const app = await webkit.postMessage("INIT");
directory = app.directory;
return app;
}
function changeDirectory() {
webkit.postMessage("CHANGE_DIRECTORY");
}
function openDirectory() {
webkit.postMessage("OPEN_DIRECTORY");
}
</script>
<main>
{#await initialize() then app}
<div class="section icons">
<img
alt="Userscripts App Icon"
class="icon"
draggable="false"
src={icon}
/>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<div class="logo">{@html logo}</div>
<div class="version">
{#if import.meta.env.GIT_TAG && import.meta.env.GIT_COMMIT}
<a href="{baseUrl}/releases/tag/{import.meta.env.GIT_TAG}">
{import.meta.env.GIT_TAG}
</a>
(<a href="{baseUrl}/commit/{import.meta.env.GIT_COMMIT}">
{import.meta.env.GIT_COMMIT.slice(0, 7)}
</a>)
{:else}
<span>v{app.version}</span>
<span>({app.build})</span>
{/if}
</div>
</div>
<div class="section guide">
<p>
You can turn on the Userscripts iOS Safari extension in Settings or
Safari, then use the extension in Safari. Please refer to the "Usage"
section in the
<a
href="{baseUrl}/blob/{import.meta.env.GIT_TAG ??
'main'}/README.md#usage">README of this version</a
>.
</p>
</div>
<div class="section action">
<button id="changedir" on:click={changeDirectory}>
Change Userscripts Directory
</button>
<div class="current">CURRENT DIRECTORY:</div>
<button id="directory" class="link" on:click={openDirectory}>
{directory}
</button>
</div>
{:catch error}
<div class="section">
{error}
</div>
{/await}
<div class="section footer">
<div class="links">
<a href="{baseUrl}/blob/{import.meta.env.GIT_TAG ?? 'main'}/README.md"
>Documentation</a
>
<a href="{baseUrl}/discussions">Discussions</a>
<a href="{baseUrl}/issues">Report an Issue</a>
<a href="{baseUrl}#privacy-policy">Privacy Policy</a>
</div>
</div>
</main>
<style>
main {
display: flex;
flex-direction: column;
place-items: center;
place-content: center;
gap: min(2rem, 32px);
min-height: 100svh;
min-height: -webkit-fill-available;
padding: 16px;
text-align: center;
-webkit-touch-callout: none;
user-select: none;
}
.section {
display: flex;
place-items: center;
flex-direction: column;
gap: min(0.5rem, 16px);
}
.section.icons,
.section.footer {
flex: 1;
place-content: flex-end;
}
.section.footer .links {
display: flex;
flex-flow: row wrap;
place-content: center;
gap: min(0.5rem, 16px);
}
a {
color: var(--color-blue);
}
.icon {
height: min(8rem, 256px);
width: min(8rem, 256px);
}
.logo :global(svg) {
display: flex;
height: min(1.5rem, 32px);
}
.links,
.version,
.current {
color: var(--text-color-disabled);
font: var(--text-small);
font-weight: bold;
letter-spacing: var(--letter-spacing-small);
}
button#changedir {
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);
padding: 0.5rem 1rem;
}
button#changedir:active {
background-color: #6296c7;
}
button#directory {
color: var(--editor-default);
font-family: var(--editor-font);
font-size: 0.875rem;
font-weight: 400;
word-break: break-all;
text-decoration: none;
}
</style>