blob: f6699312e52b86b160ce467267170d08f56e07d6 (
plain) (
blame)
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
|
<script>
const browser = window.browser || window.chrome
import utils from "../../assets/javascripts/utils.js"
import { onDestroy } from "svelte"
import servicesHelper from "../../assets/javascripts/services.js"
import { onMount } from "svelte"
import Buttons from "./Buttons.svelte"
import { options, config, page } from "./stores"
let _options
const unsubscribeOptions = options.subscribe(val => {
if (val) {
_options = val
browser.storage.local.set({ options: val })
}
})
let _config
const unsubscribeConfig = config.subscribe(val => (_config = val))
onDestroy(() => {
unsubscribeOptions()
unsubscribeConfig()
})
onMount(async () => {
let opts = await utils.getOptions()
if (!opts) {
await servicesHelper.initDefaults()
opts = await utils.getOptions()
}
options.set(opts)
config.set(await utils.getConfig())
})
let _page
page.subscribe(val => (_page = val))
let style
$: if (_options) style = utils.style(_options, window)
</script>
{#if _options && _config}
<div class="main" dir="auto" {style}>
<Buttons />
</div>
{:else}
<p>Loading...</p>
{/if}
<style>
:global(html, body) {
min-width: 260px;
height: min-content;
min-height: auto;
margin: 0;
padding: 0;
box-sizing: border-box;
}
:global(body) {
margin-top: -20px;
}
div {
font-weight: bold;
height: 100%;
margin: 0;
padding: 10px;
padding-top: 20px;
font-family: "Inter", sans-serif;
font-size: 16px;
background-color: var(--bg-main);
color: var(--text);
}
</style>
|