Added setting json export
This commit is contained in:
+1
-1
@@ -95,7 +95,7 @@ volumes:
|
||||
```
|
||||
|
||||
### Overwriting Materialious defaults
|
||||
Materialious allows you to overwrite the default values using `VITE_DEFAULT_SETTINGS`, see [SETTINGS](./SETTINGS.md) for more details.
|
||||
Materialious lets you customize the default settings by overriding them with `VITE_DEFAULT_SETTINGS`. To configure this easily, go to **Settings** → **Interface** and click "Export to JSON." For more details, check the [SETTINGS](./SETTINGS.md) page.
|
||||
|
||||
**Please note:** These overwrites only apply on 1st load & won't replace existing configuration stored in browser local storage.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { bookmarkletSaveToUrl } from '$lib/externalSettings/index';
|
||||
import { bookmarkletSaveToUrl, settingsToJson } from '$lib/externalSettings/index';
|
||||
import { letterCase, titleCases } from '$lib/letterCasing';
|
||||
import { setAmoledTheme } from '$lib/theme';
|
||||
import { Clipboard } from '@capacitor/clipboard';
|
||||
@@ -14,7 +14,8 @@
|
||||
setInvidiousInstance,
|
||||
goToInvidiousLogin,
|
||||
invidiousLogout,
|
||||
timeout
|
||||
timeout,
|
||||
shareURL
|
||||
} from '../../misc';
|
||||
import { getPages, type Pages } from '../../navPages';
|
||||
import ColorPicker from 'svelte-awesome-color-picker';
|
||||
@@ -464,14 +465,32 @@
|
||||
<button
|
||||
class="no-margin"
|
||||
onclick={async () => {
|
||||
await Clipboard.write({ string: bookmarkletSaveToUrl() });
|
||||
await shareURL(bookmarkletSaveToUrl());
|
||||
}}
|
||||
>
|
||||
<i>content_copy</i>
|
||||
<span>{$_('copyUrl')}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="space"></div>
|
||||
<div class="settings">
|
||||
<h6>{$_('layout.exportToJson')}</h6>
|
||||
<div class="space"></div>
|
||||
<button
|
||||
class="no-margin"
|
||||
onclick={async () => {
|
||||
await Clipboard.write({ string: settingsToJson() });
|
||||
|
||||
addToast({
|
||||
data: {
|
||||
text: $_('player.share.copiedSuccess')
|
||||
text: get(_)('player.share.copiedSuccess')
|
||||
}
|
||||
});
|
||||
}}>{$_('copyUrl')}</button
|
||||
}}
|
||||
>
|
||||
<i>content_copy</i>
|
||||
<span>{$_('copy')}</span>
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -117,6 +117,19 @@ export function bookmarkletSaveToUrl(): string {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
export function settingsToJson(): string {
|
||||
const settings: Record<string, string> = {};
|
||||
|
||||
for (const { name, store, excludeFromBookmarklet } of persistedStores) {
|
||||
const value = get(store);
|
||||
if (!excludeFromBookmarklet) {
|
||||
settings[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return JSON.stringify(settings);
|
||||
}
|
||||
|
||||
export function bookmarkletLoadFromUrl() {
|
||||
const toSet: Record<string, string> = {};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"popularPageDisabled": "Popular page has been disabled by Admins",
|
||||
"premium": "Premium YouTube content can't be watched on Materialious.",
|
||||
"copyUrl": "Copy URL",
|
||||
"copy": "Copy JSON",
|
||||
"loadMore": "Load more",
|
||||
"views": "views",
|
||||
"login": "Login",
|
||||
@@ -237,6 +238,7 @@
|
||||
"playerStatistics": "Show player statistics by default"
|
||||
},
|
||||
"bookmarklet": "Bookmarklet",
|
||||
"exportToJson": "Export to JSON",
|
||||
"instanceUrl": "Instance URL",
|
||||
"sponsors": {
|
||||
"sponsor": "Sponsor",
|
||||
|
||||
Reference in New Issue
Block a user