Browse Source

Add missing iconography on archives and native 4chan

pull/46/head
coomdev 2 years ago
parent
commit
c78cb5f3ca
  1. 2
      main.meta.js
  2. 87
      main.user.js
  3. 69
      src/Components/EyeButton.svelte

2
main.meta.js

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name PNGExtraEmbed // @name PNGExtraEmbed
// @namespace https://coom.tech/ // @namespace https://coom.tech/
// @version 0.185 // @version 0.186
// @description uhh // @description uhh
// @author You // @author You
// @match https://boards.4channel.org/* // @match https://boards.4channel.org/*

87
main.user.js

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name PNGExtraEmbed // @name PNGExtraEmbed
// @namespace https://coom.tech/ // @namespace https://coom.tech/
// @version 0.185 // @version 0.186
// @description uhh // @description uhh
// @author You // @author You
// @match https://boards.4channel.org/* // @match https://boards.4channel.org/*
@ -81,7 +81,7 @@
var define_BUILD_VERSION_default; var define_BUILD_VERSION_default;
var init_define_BUILD_VERSION = __esm({ var init_define_BUILD_VERSION = __esm({
"<define:BUILD_VERSION>"() { "<define:BUILD_VERSION>"() {
define_BUILD_VERSION_default = [0, 185]; define_BUILD_VERSION_default = [0, 186];
} }
}); });
@ -26910,28 +26910,34 @@
} }
function get_each_context5(ctx, list, i) { function get_each_context5(ctx, list, i) {
const child_ctx = ctx.slice(); const child_ctx = ctx.slice();
child_ctx[11] = list[i]; child_ctx[12] = list[i];
return child_ctx; return child_ctx;
} }
function create_if_block_33(ctx) { function create_if_block_33(ctx) {
let span; let span;
let t_value = ctx[5].is4chanX ? "" : !ctx[3] ? "\u{1F441}" : "\u{1F926}";
let t;
let mounted; let mounted;
let dispose; let dispose;
return { return {
c() { c() {
span = element("span"); span = element("span");
t = text(t_value);
attr(span, "class", "fa clickable svelte-64lw6s"); attr(span, "class", "fa clickable svelte-64lw6s");
toggle_class(span, "fa-eye", !ctx[3]); toggle_class(span, "fa-eye", !ctx[3]);
toggle_class(span, "fa-eye-slash", ctx[3]); toggle_class(span, "fa-eye-slash", ctx[3]);
}, },
m(target, anchor) { m(target, anchor) {
insert(target, span, anchor); insert(target, span, anchor);
append(span, t);
if (!mounted) { if (!mounted) {
dispose = listen(span, "click", ctx[5]); dispose = listen(span, "click", ctx[6]);
mounted = true; mounted = true;
} }
}, },
p(ctx2, dirty) { p(ctx2, dirty) {
if (dirty & 40 && t_value !== (t_value = ctx2[5].is4chanX ? "" : !ctx2[3] ? "\u{1F441}" : "\u{1F926}"))
set_data(t, t_value);
if (dirty & 8) { if (dirty & 8) {
toggle_class(span, "fa-eye", !ctx2[3]); toggle_class(span, "fa-eye", !ctx2[3]);
} }
@ -26955,7 +26961,7 @@
c() { c() {
a = element("a"); a = element("a");
t = text("Source"); t = text("Source");
attr(a, "href", a_href_value = ctx[11].source); attr(a, "href", a_href_value = ctx[12].source);
attr(a, "target", "_blank"); attr(a, "target", "_blank");
attr(a, "class", "clickable svelte-64lw6s"); attr(a, "class", "clickable svelte-64lw6s");
}, },
@ -26964,7 +26970,7 @@
append(a, t); append(a, t);
}, },
p(ctx2, dirty) { p(ctx2, dirty) {
if (dirty & 1 && a_href_value !== (a_href_value = ctx2[11].source)) { if (dirty & 1 && a_href_value !== (a_href_value = ctx2[12].source)) {
attr(a, "href", a_href_value); attr(a, "href", a_href_value);
} }
}, },
@ -26976,14 +26982,14 @@
} }
function create_if_block_13(ctx) { function create_if_block_13(ctx) {
let a; let a;
let t_value = ctx[11].page.title + ""; let t_value = ctx[12].page.title + "";
let t; let t;
let a_href_value; let a_href_value;
return { return {
c() { c() {
a = element("a"); a = element("a");
t = text(t_value); t = text(t_value);
attr(a, "href", a_href_value = ctx[11].page.url); attr(a, "href", a_href_value = ctx[12].page.url);
attr(a, "target", "_blank"); attr(a, "target", "_blank");
attr(a, "class", "clickable svelte-64lw6s"); attr(a, "class", "clickable svelte-64lw6s");
}, },
@ -26992,9 +26998,9 @@
append(a, t); append(a, t);
}, },
p(ctx2, dirty) { p(ctx2, dirty) {
if (dirty & 1 && t_value !== (t_value = ctx2[11].page.title + "")) if (dirty & 1 && t_value !== (t_value = ctx2[12].page.title + ""))
set_data(t, t_value); set_data(t, t_value);
if (dirty & 1 && a_href_value !== (a_href_value = ctx2[11].page.url)) { if (dirty & 1 && a_href_value !== (a_href_value = ctx2[12].page.url)) {
attr(a, "href", a_href_value); attr(a, "href", a_href_value);
} }
}, },
@ -27018,7 +27024,7 @@
m(target, anchor) { m(target, anchor) {
insert(target, a, anchor); insert(target, a, anchor);
if (!mounted) { if (!mounted) {
dispose = listen(a, "click", ctx[10]); dispose = listen(a, "click", ctx[11]);
mounted = true; mounted = true;
} }
}, },
@ -27033,44 +27039,48 @@
} }
function create_each_block5(ctx) { function create_each_block5(ctx) {
let span; let span;
let span_title_value; let t0_value = ctx[5].is4chanX ? "" : "\u{1F5AB}";
let t0; let t0;
let span_title_value;
let t1; let t1;
let t2; let t2;
let t3;
let if_block2_anchor; let if_block2_anchor;
let mounted; let mounted;
let dispose; let dispose;
function click_handler2() { function click_handler2() {
return ctx[9](ctx[11]); return ctx[10](ctx[12]);
} }
let if_block0 = ctx[11].source && create_if_block_23(ctx); let if_block0 = ctx[12].source && create_if_block_23(ctx);
let if_block1 = ctx[11].page && create_if_block_13(ctx); let if_block1 = ctx[12].page && create_if_block_13(ctx);
let if_block2 = ctx[6] && ctx[2] && create_if_block9(ctx); let if_block2 = ctx[7] && ctx[2] && create_if_block9(ctx);
return { return {
c() { c() {
span = element("span"); span = element("span");
t0 = space(); t0 = text(t0_value);
t1 = space();
if (if_block0) if (if_block0)
if_block0.c(); if_block0.c();
t1 = space(); t2 = space();
if (if_block1) if (if_block1)
if_block1.c(); if_block1.c();
t2 = space(); t3 = space();
if (if_block2) if (if_block2)
if_block2.c(); if_block2.c();
if_block2_anchor = empty(); if_block2_anchor = empty();
attr(span, "title", span_title_value = ctx[11].filename); attr(span, "title", span_title_value = ctx[12].filename);
attr(span, "class", "fa fa-download clickable svelte-64lw6s"); attr(span, "class", "fa fa-download clickable svelte-64lw6s");
}, },
m(target, anchor) { m(target, anchor) {
insert(target, span, anchor); insert(target, span, anchor);
insert(target, t0, anchor); append(span, t0);
insert(target, t1, anchor);
if (if_block0) if (if_block0)
if_block0.m(target, anchor); if_block0.m(target, anchor);
insert(target, t1, anchor); insert(target, t2, anchor);
if (if_block1) if (if_block1)
if_block1.m(target, anchor); if_block1.m(target, anchor);
insert(target, t2, anchor); insert(target, t3, anchor);
if (if_block2) if (if_block2)
if_block2.m(target, anchor); if_block2.m(target, anchor);
insert(target, if_block2_anchor, anchor); insert(target, if_block2_anchor, anchor);
@ -27081,34 +27091,36 @@
}, },
p(new_ctx, dirty) { p(new_ctx, dirty) {
ctx = new_ctx; ctx = new_ctx;
if (dirty & 1 && span_title_value !== (span_title_value = ctx[11].filename)) { if (dirty & 32 && t0_value !== (t0_value = ctx[5].is4chanX ? "" : "\u{1F5AB}"))
set_data(t0, t0_value);
if (dirty & 1 && span_title_value !== (span_title_value = ctx[12].filename)) {
attr(span, "title", span_title_value); attr(span, "title", span_title_value);
} }
if (ctx[11].source) { if (ctx[12].source) {
if (if_block0) { if (if_block0) {
if_block0.p(ctx, dirty); if_block0.p(ctx, dirty);
} else { } else {
if_block0 = create_if_block_23(ctx); if_block0 = create_if_block_23(ctx);
if_block0.c(); if_block0.c();
if_block0.m(t1.parentNode, t1); if_block0.m(t2.parentNode, t2);
} }
} else if (if_block0) { } else if (if_block0) {
if_block0.d(1); if_block0.d(1);
if_block0 = null; if_block0 = null;
} }
if (ctx[11].page) { if (ctx[12].page) {
if (if_block1) { if (if_block1) {
if_block1.p(ctx, dirty); if_block1.p(ctx, dirty);
} else { } else {
if_block1 = create_if_block_13(ctx); if_block1 = create_if_block_13(ctx);
if_block1.c(); if_block1.c();
if_block1.m(t2.parentNode, t2); if_block1.m(t3.parentNode, t3);
} }
} else if (if_block1) { } else if (if_block1) {
if_block1.d(1); if_block1.d(1);
if_block1 = null; if_block1 = null;
} }
if (ctx[6] && ctx[2]) { if (ctx[7] && ctx[2]) {
if (if_block2) { if (if_block2) {
if_block2.p(ctx, dirty); if_block2.p(ctx, dirty);
} else { } else {
@ -27125,15 +27137,15 @@
if (detaching) if (detaching)
detach(span); detach(span);
if (detaching) if (detaching)
detach(t0); detach(t1);
if (if_block0) if (if_block0)
if_block0.d(detaching); if_block0.d(detaching);
if (detaching) if (detaching)
detach(t1); detach(t2);
if (if_block1) if (if_block1)
if_block1.d(detaching); if_block1.d(detaching);
if (detaching) if (detaching)
detach(t2); detach(t3);
if (if_block2) if (if_block2)
if_block2.d(detaching); if_block2.d(detaching);
if (detaching) if (detaching)
@ -27184,7 +27196,7 @@
if_block.d(1); if_block.d(1);
if_block = null; if_block = null;
} }
if (dirty & 199) { if (dirty & 423) {
each_value = ctx2[0]; each_value = ctx2[0];
let i; let i;
for (i = 0; i < each_value.length; i += 1) { for (i = 0; i < each_value.length; i += 1) {
@ -27218,7 +27230,9 @@
} }
function instance14($$self, $$props, $$invalidate) { function instance14($$self, $$props, $$invalidate) {
let $settings; let $settings;
let $appState;
component_subscribe($$self, settings, ($$value) => $$invalidate(4, $settings = $$value)); component_subscribe($$self, settings, ($$value) => $$invalidate(4, $settings = $$value));
component_subscribe($$self, appState, ($$value) => $$invalidate(5, $appState = $$value));
let { id = "" } = $$props; let { id = "" } = $$props;
let { files } = $$props; let { files } = $$props;
let { inst } = $$props; let { inst } = $$props;
@ -27254,7 +27268,7 @@
}; };
$$self.$$set = ($$props2) => { $$self.$$set = ($$props2) => {
if ("id" in $$props2) if ("id" in $$props2)
$$invalidate(8, id = $$props2.id); $$invalidate(9, id = $$props2.id);
if ("files" in $$props2) if ("files" in $$props2)
$$invalidate(0, files = $$props2.files); $$invalidate(0, files = $$props2.files);
if ("inst" in $$props2) if ("inst" in $$props2)
@ -27266,6 +27280,7 @@
isVideo, isVideo,
visible, visible,
$settings, $settings,
$appState,
reveal, reveal,
isNotChrome, isNotChrome,
downloadFile, downloadFile,
@ -27277,10 +27292,10 @@
var EyeButton = class extends SvelteComponent { var EyeButton = class extends SvelteComponent {
constructor(options) { constructor(options) {
super(); super();
init(this, options, instance14, create_fragment14, safe_not_equal, { id: 8, files: 0, inst: 1 }, add_css12); init(this, options, instance14, create_fragment14, safe_not_equal, { id: 9, files: 0, inst: 1 }, add_css12);
} }
get id() { get id() {
return this.$$.ctx[8]; return this.$$.ctx[9];
} }
set id(id) { set id(id) {
this.$$set({ id }); this.$$set({ id });

69
src/Components/EyeButton.svelte

@ -1,45 +1,44 @@
<script lang="ts"> <script lang="ts">
import { fileTypeFromBuffer } from 'file-type' import { fileTypeFromBuffer } from "file-type";
import { Buffer } from 'buffer' import { Buffer } from "buffer";
import type Embedding from './Embedding.svelte' import type Embedding from "./Embedding.svelte";
import type Embeddings from './Embeddings.svelte' import type Embeddings from "./Embeddings.svelte";
import type { EmbeddedFile } from '../main' import type { EmbeddedFile } from "../main";
import { settings } from '../stores' import { appState, settings } from "../stores";
export let id = '' export let id = "";
export let files: EmbeddedFile[] export let files: EmbeddedFile[];
export let inst: Embedding | Embeddings export let inst: Embedding | Embeddings;
let isVideo = false let isVideo = false;
inst.$on('fileinfo', (info) => { inst.$on("fileinfo", (info) => {
isVideo = isVideo || info.detail.type.mime.startsWith('video/') isVideo = isVideo || info.detail.type.mime.startsWith("video/");
}) });
let visible = false let visible = false;
function reveal() { function reveal() {
visible = !visible visible = !visible;
document.dispatchEvent(new CustomEvent('reveal', { detail: { id } })) document.dispatchEvent(new CustomEvent("reveal", { detail: { id } }));
} }
const isNotChrome = !navigator.userAgent.includes('Chrome/') const isNotChrome = !navigator.userAgent.includes("Chrome/");
async function downloadFile(file: EmbeddedFile) { async function downloadFile(file: EmbeddedFile) {
const a = document.createElement('a') as HTMLAnchorElement const a = document.createElement("a") as HTMLAnchorElement;
document.body.appendChild(a) document.body.appendChild(a);
a.style.display = 'none' a.style.display = "none";
let url: string let url: string;
if (typeof file.data != "string") { if (typeof file.data != "string") {
const thumb = (Buffer.isBuffer(file.data) ? file.data : await file.data()) const thumb = Buffer.isBuffer(file.data) ? file.data : await file.data();
const type = await fileTypeFromBuffer(thumb) const type = await fileTypeFromBuffer(thumb);
url = URL.createObjectURL(new Blob([thumb], { type: type?.mime })) url = URL.createObjectURL(new Blob([thumb], { type: type?.mime }));
} else } else url = file.data;
url = file.data; a.href = url;
a.href = url a.download = file.filename;
a.download = file.filename a.click();
a.click() window.URL.revokeObjectURL(url);
window.URL.revokeObjectURL(url)
} }
</script> </script>
@ -49,14 +48,18 @@
class:fa-eye={!visible} class:fa-eye={!visible}
class:fa-eye-slash={visible} class:fa-eye-slash={visible}
class="fa clickable" class="fa clickable"
/> >
{$appState.is4chanX ? "" : !visible ? "👁" : "🤦"}
</span>
{/if} {/if}
{#each files as file} {#each files as file}
<span <span
title={file.filename} title={file.filename}
on:click={() => downloadFile(file)} on:click={() => downloadFile(file)}
class="fa fa-download clickable" class="fa fa-download clickable"
/> >
{$appState.is4chanX ? "" : "🖫"}
</span>
{#if file.source} {#if file.source}
<!-- svelte-ignore a11y-missing-content --> <!-- svelte-ignore a11y-missing-content -->
<a href={file.source} target="_blank" class="clickable">Source</a> <a href={file.source} target="_blank" class="clickable">Source</a>
@ -71,7 +74,7 @@
<!-- svelte-ignore a11y-missing-attribute --> <!-- svelte-ignore a11y-missing-attribute -->
<a <a
on:click={(ev) => { on:click={(ev) => {
inst.bepis(ev) inst.bepis(ev);
}} }}
alt="By clicking this you agree to stay hydrated" alt="By clicking this you agree to stay hydrated"
class="clickable">[PEE contract]</a class="clickable">[PEE contract]</a

Loading…
Cancel
Save