Browse Source

Auto-refresh when opening thread watcher

pull/46/head
coomdev 2 years ago
parent
commit
3c539aad15
  1. 492
      src/Components/App.svelte
  2. 5
      src/Components/Tab.svelte
  3. 3
      src/Components/Tabs.svelte

492
src/Components/App.svelte

@ -1,5 +1,7 @@
<script lang="ts"> <script lang="ts">
import { hasContext, onDestroy } from "svelte"; import { hasContext, onDestroy } from "svelte";
import { slide } from "svelte/transition";
import Dialog from "./Dialog.svelte"; import Dialog from "./Dialog.svelte";
import Tag from "./Tag.svelte"; import Tag from "./Tag.svelte";
@ -45,7 +47,13 @@
const boardname = location.pathname.match(/\/([^/]*)\//)![1]; const boardname = location.pathname.match(/\/([^/]*)\//)![1];
let updating = false; let updating = false;
let threads: { id: number; cnt: number }[] = []; let threads: {
id: number;
cnt: number;
pees: number;
eyes: number;
other: number;
}[] = [];
async function updateThreads() { async function updateThreads() {
updating = true; updating = true;
let params = ""; let params = "";
@ -82,276 +90,278 @@
}); });
</script> </script>
<div class="backpanel" class:enabled={visible} class:disabled={!visible}> {#if visible}
<div class="content"> <div class="backpanel" transition:slide>
<h1>PEE Settings</h1> <div class="content">
<hr /> <h1>PEE Settings</h1>
<Tabs> <hr />
<TabList> <Tabs>
<Tab>General</Tab> <TabList>
<Tab>External</Tab> <Tab>General</Tab>
<Tab>File Host</Tab> <Tab>External</Tab>
<Tab>Thread Watcher</Tab> <Tab>File Host</Tab>
{#if $appState.akValid} <Tab on:select={() => updateThreads()}>Thread Watcher</Tab>
<Tab>Hydrus</Tab> {#if $appState.akValid}
{/if} <Tab>Hydrus</Tab>
</TabList> {/if}
<TabPanel> </TabList>
<label> <TabPanel>
<input type="checkbox" bind:checked={$cached} /> <label>
Try to load embeds from server cache <input type="checkbox" bind:checked={$cached} />
</label> Try to load embeds from server cache
<label> </label>
<input type="checkbox" bind:checked={$settings.dvc} /> <label>
Display view counts <input type="checkbox" bind:checked={$settings.dvc} />
</label> Display view counts
<label> </label>
<input type="checkbox" bind:checked={$settings.vercheck} /> <label>
Check for new versions at startup. <input type="checkbox" bind:checked={$settings.vercheck} />
</label> Check for new versions at startup.
<label> </label>
<input type="checkbox" bind:checked={$settings.xpi} /> <label>
Autoexpand Images on opening. <input type="checkbox" bind:checked={$settings.xpi} />
</label> Autoexpand Images on opening.
<label> </label>
<input type="checkbox" bind:checked={$settings.xpv} /> <label>
Autoexpand Videos on opening. <input type="checkbox" bind:checked={$settings.xpv} />
</label> Autoexpand Videos on opening.
<label> </label>
<input type="checkbox" bind:checked={$settings.loop} /> <label>
Loop media content. <input type="checkbox" bind:checked={$settings.loop} />
</label> Loop media content.
<label> </label>
<input type="checkbox" bind:checked={$settings.dh} /> <label>
Disable hover preview. <input type="checkbox" bind:checked={$settings.dh} />
</label> Disable hover preview.
</label>
<label>
<input type="checkbox" bind:checked={$settings.eye} />
Hide embedded content behind an eye.
</label>
{#if $settings.eye}
<label> <label>
<input type="checkbox" bind:checked={$settings.ho} /> <input type="checkbox" bind:checked={$settings.eye} />
Hide original content when hidden content is visible. Hide embedded content behind an eye.
</label> </label>
{/if} {#if $settings.eye}
<label> <label>
<input type="checkbox" bind:checked={$settings.pre} /> <input type="checkbox" bind:checked={$settings.ho} />
Preload external files. Hide original content when hidden content is visible.
</label> </label>
<label>
<input type="checkbox" bind:checked={$settings.prev} />
Preload external files when they are in view.
</label>
<label>
<input type="checkbox" bind:checked={$settings.hotlink} />
Hotlink content.
</label>
<label>
<input type="checkbox" bind:checked={$settings.ca} />
Control audio on videos with mouse wheel.
</label>
<label>
<input type="checkbox" bind:checked={$settings.sh} />
Show Minimap
</label>
<label>
<input type="checkbox" bind:checked={$settings.ep} />
<!-- svelte-ignore a11y-missing-attribute -->
Disable embedded file preloading<a
title="You might still want to enable 'preload external files'">?</a
>
</label>
<label>
<input type="checkbox" bind:checked={$settings.hyd} />
<!-- svelte-ignore a11y-missing-attribute -->
Enable Hydrus Integration
</label>
{#if $settings.hyd}
{#if $appState.herror}
<span class="error">{$appState.herror}</span>
{/if} {/if}
<label> <label>
Hydrus Access Key <input type="checkbox" bind:checked={$settings.pre} />
Preload external files.
</label>
<label>
<input type="checkbox" bind:checked={$settings.prev} />
Preload external files when they are in view.
</label>
<label>
<input type="checkbox" bind:checked={$settings.hotlink} />
Hotlink content.
</label>
<label>
<input type="checkbox" bind:checked={$settings.ca} />
Control audio on videos with mouse wheel.
</label>
<label>
<input type="checkbox" bind:checked={$settings.sh} />
Show Minimap
</label>
<label>
<input type="checkbox" bind:checked={$settings.ep} />
<!-- svelte-ignore a11y-missing-attribute --> <!-- svelte-ignore a11y-missing-attribute -->
<a Disable embedded file preloading<a
title="Only requires Search Files permission. See Hydrus docs on where to set this up." title="You might still want to enable 'preload external files'"
>?</a >?</a
> >
<input type="text" bind:value={$settings.ak} />
</label> </label>
{#if $appState.akValid}
<label>
Auto-embed <input
style="width: 5ch;"
type="number"
bind:value={$settings.auto_embed}
/>
random files
<!-- svelte-ignore a11y-missing-attribute -->
</label>
<label>
<!-- svelte-ignore a11y-missing-attribute -->
<input
placeholder="Restrict to these tags (space to separate tags, _ to separate words)"
type="text"
bind:value={$settings.auto_tags}
/>
</label>
{/if}
{/if}
</TabPanel>
<TabPanel>
<label>
<input type="checkbox" bind:checked={$settings.te} />
Disable third-eye.
</label>
{#if !$settings.te}
<label> <label>
<input type="checkbox" bind:checked={$settings.phash} /> <input type="checkbox" bind:checked={$settings.hyd} />
Enable perceptual hash-based filtering <!-- svelte-ignore a11y-missing-attribute -->
Enable Hydrus Integration
</label> </label>
{#if $settings.phash} {#if $settings.hyd}
{#if $appState.herror}
<span class="error">{$appState.herror}</span>
{/if}
<label> <label>
<input type="number" bind:value={$settings.mdist} /> Hydrus Access Key
Minimum distance required (5 recommended)
<!-- svelte-ignore a11y-missing-attribute --> <!-- svelte-ignore a11y-missing-attribute -->
<a <a
title="Higher will filter more potentially different images, lower will let more identical images through" title="Only requires Search Files permission. See Hydrus docs on where to set this up."
>?</a >?</a
> >
<input type="text" bind:value={$settings.ak} />
</label> </label>
{/if} {#if $appState.akValid}
<h3>Booru sources</h3>
<div class="tagcont">
{#each $settings.rsources as source, i}
<Tag
tag={source.name}
on:remove={() => removeBooru(source.domain)}
on:toggle={() => toggleBooru(source.domain)}
toggleable={true}
toggled={!$settings.rsources.find(
(e) => e.domain == source.domain
)?.disabled}
/>
{/each}
</div>
<button
on:click={(ev) => {
dial.setPos([ev.clientX, ev.clientY]);
dial.toggle();
}}>Add a source</button
>
<Dialog bind:this={dial}>
<div class="form">
<label> <label>
Name Auto-embed <input
<input style="width: 5ch;"
type="text" type="number"
placeholder="Gelbooru" bind:value={$settings.auto_embed}
bind:value={newbooru.name}
/> />
random files
<!-- svelte-ignore a11y-missing-attribute -->
</label> </label>
<label> <label>
Domain <!-- svelte-ignore a11y-missing-attribute -->
<input <input
placeholder="Restrict to these tags (space to separate tags, _ to separate words)"
type="text" type="text"
placeholder="gelbooru.com" bind:value={$settings.auto_tags}
bind:value={newbooru.domain}
/> />
</label> </label>
{/if}
{/if}
</TabPanel>
<TabPanel>
<label>
<input type="checkbox" bind:checked={$settings.te} />
Disable third-eye.
</label>
{#if !$settings.te}
<label>
<input type="checkbox" bind:checked={$settings.phash} />
Enable perceptual hash-based filtering
</label>
{#if $settings.phash}
<label> <label>
API Endpoint <input type="number" bind:value={$settings.mdist} />
<input Minimum distance required (5 recommended)
type="text" <!-- svelte-ignore a11y-missing-attribute -->
placeholder="/post.json?tags=md5:" <a
bind:value={newbooru.endpoint} title="Higher will filter more potentially different images, lower will let more identical images through"
/> >?</a
>
</label> </label>
<label> {/if}
Post page prefix (for sources) <h3>Booru sources</h3>
<input <div class="tagcont">
type="text" {#each $settings.rsources as source, i}
placeholder="https://yande.re/post/show/" <Tag
bind:value={newbooru.view} tag={source.name}
on:remove={() => removeBooru(source.domain)}
on:toggle={() => toggleBooru(source.domain)}
toggleable={true}
toggled={!$settings.rsources.find(
(e) => e.domain == source.domain
)?.disabled}
/> />
</label> {/each}
<button on:click={appendBooru}>Add</button>
</div> </div>
</Dialog> <button
on:click={(ev) => {
dial.setPos([ev.clientX, ev.clientY]);
dial.toggle();
}}>Add a source</button
>
<Dialog bind:this={dial}>
<div class="form">
<label>
Name
<input
type="text"
placeholder="Gelbooru"
bind:value={newbooru.name}
/>
</label>
<label>
Domain
<input
type="text"
placeholder="gelbooru.com"
bind:value={newbooru.domain}
/>
</label>
<label>
API Endpoint
<input
type="text"
placeholder="/post.json?tags=md5:"
bind:value={newbooru.endpoint}
/>
</label>
<label>
Post page prefix (for sources)
<input
type="text"
placeholder="https://yande.re/post/show/"
bind:value={newbooru.view}
/>
</label>
<button on:click={appendBooru}>Add</button>
</div>
</Dialog>
<hr /> <hr />
<h3>Blacklisted tags</h3> <h3>Blacklisted tags</h3>
<div class="tagcont"> <div class="tagcont">
{#each $settings.blacklist as tag, i} {#each $settings.blacklist as tag, i}
<Tag {tag} on:toggle={() => removeTag(tag)} /> <Tag {tag} on:toggle={() => removeTag(tag)} />
{/each}
</div>
<input
placeholder="Press enter after typing your tag"
on:keydown={(ev) => {
if (ev.key == "Enter") {
$settings.blacklist = [
...$settings.blacklist,
ev.currentTarget.value,
];
ev.currentTarget.value = "";
}
}}
/>
{/if}
</TabPanel>
<TabPanel>
<p>Host to use when uploading files (Only permanent hosts)</p>
<select bind:value={$settings.fhost}>
{#each filehosts as fh, i}
<option value={i}>{fh.domain}</option>
{/each} {/each}
</div> </select>
<input <label>
placeholder="Press enter after typing your tag" Maximum number of embedded links to display
on:keydown={(ev) => { <input type="number" bind:value={$settings.maxe} />
if (ev.key == "Enter") { </label>
$settings.blacklist = [ </TabPanel>
...$settings.blacklist, <TabPanel>
ev.currentTarget.value, <label>
]; <input type="checkbox" bind:checked={$settings.tm} />
ev.currentTarget.value = ""; <!-- svelte-ignore a11y-missing-attribute -->
} Contribute to help keep this list up to date. [<a
}} title="This will make PEE automatically send the
/>
{/if}
</TabPanel>
<TabPanel>
<p>Host to use when uploading files (Only permanent hosts)</p>
<select bind:value={$settings.fhost}>
{#each filehosts as fh, i}
<option value={i}>{fh.domain}</option>
{/each}
</select>
<label>
Maximum number of embedded links to display
<input type="number" bind:value={$settings.maxe} />
</label>
</TabPanel>
<TabPanel>
<label>
<input type="checkbox" bind:checked={$settings.tm} />
<!-- svelte-ignore a11y-missing-attribute -->
Contribute to help keep this list up to date. [<a
title="This will make PEE automatically send the
post number of posts you find with embedded content">?</a post number of posts you find with embedded content">?</a
>] >]
</label> </label>
<button on:click={updateThreads} disabled={updating}>Refresh</button>
{#if !updating} {#if !updating}
<div class="bepis"> <div class="bepis">
{#each threads as thread} <p>Format is (embedded links / link in filename)</p>
<div class="mbepis"> {#each threads as thread}
<a <div class="mbepis">
href={"https://boards.4chan.org/" + <a
boardname + href={"https://boards.4chan.org/" +
"/thread/" + boardname +
thread.id}>>>{thread.id}</a "/thread/" +
> thread.id}>>>{thread.id}</a
({thread.cnt} embeds) >
</div> ({thread.pees} / {thread.eyes + thread.other})
{/each} </div>
</div> {/each}
{:else} </div>
<p>Loading...</p> {:else}
{/if} <p>Loading...</p>
</TabPanel> {/if}
{#if $appState.akValid}
<TabPanel>
<HydrusSearch />
</TabPanel> </TabPanel>
{/if} {#if $appState.akValid}
</Tabs> <TabPanel>
<HydrusSearch />
</TabPanel>
{/if}
</Tabs>
</div>
</div> </div>
</div> {/if}
<style scoped> <style scoped>
.bepis { .bepis {
@ -371,14 +381,6 @@
width: 95%; width: 95%;
} }
.enabled {
display: block;
}
.disabled {
display: none;
}
.content { .content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -420,7 +422,7 @@
top: 32px; top: 32px;
border: 1px solid; border: 1px solid;
border-radius: 5px; border-radius: 5px;
background-color: rgba(0, 0, 0, 0.2); background-color: rgba(0, 0, 0, 0.8);
pointer-events: all; pointer-events: all;
backdrop-filter: blur(9px); backdrop-filter: blur(9px);
max-height: 80vh; max-height: 80vh;

5
src/Components/Tab.svelte

@ -1,14 +1,15 @@
<script lang="ts"> <script lang="ts">
import { getContext } from 'svelte' import { createEventDispatcher, getContext } from 'svelte'
import { TABS } from './Tabs.svelte' import { TABS } from './Tabs.svelte'
const tab = {} const tab = {}
const { registerTab, selectTab, selectedTab } = getContext(TABS) const { registerTab, selectTab, selectedTab } = getContext(TABS)
const dispatch = createEventDispatcher();
registerTab(tab) registerTab(tab)
</script> </script>
<button class:selected={$selectedTab === tab} on:click={() => selectTab(tab)}> <button class:selected={$selectedTab === tab} on:click={() => {selectTab(tab); dispatch("select")}}>
<slot /> <slot />
</button> </button>

3
src/Components/Tabs.svelte

@ -1,9 +1,10 @@
<script context="module"> <script context="module">
export const TABS = {} export const TABS = {}
</script> </script>
<script lang="ts"> <script lang="ts">
import { setContext, onDestroy } from 'svelte' import { setContext, onDestroy, createEventDispatcher } from 'svelte'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import type Tab from './Tab.svelte' import type Tab from './Tab.svelte'
import type TabPanel from './TabPanel.svelte' import type TabPanel from './TabPanel.svelte'

Loading…
Cancel
Save