Browse Source

Fix #9, adjust CSS to be more compact/more consistent

pull/46/head latest
coomdev 2 years ago
parent
commit
d52e5863be
  1. 1
      build.js
  2. 3
      main.meta.js
  3. 40
      main.user.js
  4. 2
      src/Embedding.svelte
  5. 4
      src/global.css
  6. 34
      src/main.ts

1
build.js

@ -25,6 +25,7 @@ const extheader = `// ==UserScript==
// @connect 4chan.org
// @connect 4channel.org
// @connect i.4cdn.org
// @icon https://coom.tech/resources/assets/1449696017588.png
// ==/UserScript==
`;

3
main.meta.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.82
// @version 0.84
// @description uhh
// @author You
// @match https://boards.4channel.org/*
@ -14,4 +14,5 @@
// @connect 4chan.org
// @connect 4channel.org
// @connect i.4cdn.org
// @icon https://coom.tech/resources/assets/1449696017588.png
// ==/UserScript==

40
main.user.js

@ -1,7 +1,7 @@
// ==UserScript==
// @name PNGExtraEmbed
// @namespace https://coom.tech/
// @version 0.82
// @version 0.84
// @description uhh
// @author You
// @match https://boards.4channel.org/*
@ -14,6 +14,7 @@
// @connect 4chan.org
// @connect 4channel.org
// @connect i.4cdn.org
// @icon https://coom.tech/resources/assets/1449696017588.png
// ==/UserScript==
(() => {
var __create = Object.create;
@ -10896,7 +10897,7 @@
});
// src/global.css
var global_default = ".pee-hidden {\n display: none;\n}\n\n.extractedImg {\n width: auto;\n height: auto;\n max-width: 125px;\n max-height: 125px;\n cursor: pointer;\n}\n\n#delform .postContainer>div.hasembed {\n border-right: 3px dashed deeppink !important;\n}\n\n.hasembed.catalog-post {\n border: 3px dashed deeppink !important;\n}\n\n#delform .postContainer>div.hasext {\n border-right: 3px dashed goldenrod !important;\n}\n\n.hasext.catalog-post {\n border: 3px dashed goldenrod !important;\n}\n\n.expanded-image>.post>.file .fileThumb>img[data-md5] {\n display: none;\n}\n\n.expanded-image>.post>.file .fileThumb .full-image {\n display: inline;\n}\n\n.pee-settings {\n position: fixed;\n top: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n}\n\ndiv.hasemb .catalog-host img {\n border: 1px solid deeppink;\n}\n\ndiv.hasext .catalog-host img {\n border: 1px solid goldenrod;\n}\n\n.catalog-host img {\n position: absolute;\n top: -5px;\n right: 0px;\n max-width: 80px;\n max-height: 80px;\n box-shadow: 0px 0px 4px 2px #00000090;\n}";
var global_default = ".pee-hidden {\n display: none;\n}\n\n.extractedImg {\n width: auto;\n height: auto;\n max-width: 125px;\n max-height: 125px;\n cursor: pointer;\n}\n\n#delform .postContainer>div.hasembed {\n border-right: 3px dashed deeppink !important;\n}\n\n.hasembed.catalog-post {\n border: 3px dashed deeppink !important;\n}\n\n#delform .postContainer>div.hasext {\n border-right: 3px dashed goldenrod !important;\n}\n\n.hasext.catalog-post {\n border: 3px dashed goldenrod !important;\n}\n\n.expanded-image>.post>.file .fileThumb>img[data-md5] {\n display: none;\n}\n\n.expanded-image>.post>.file .fileThumb .full-image {\n display: inline;\n}\n\n.pee-settings {\n position: fixed;\n top: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n}\n\ndiv.hasemb .catalog-host img {\n border: 1px solid deeppink;\n}\n\ndiv.hasext .catalog-host img {\n border: 1px solid goldenrod;\n}\n\n.catalog-host img {\n position: absolute;\n top: -5px;\n right: 0px;\n max-width: 80px;\n max-height: 80px;\n box-shadow: 0px 0px 4px 2px #00000090;\n}\n\n.fileThumb.filehost {\n margin-left: 0 !important;\n}";
// src/png.ts
init_esbuild_inject();
@ -13900,7 +13901,7 @@
t4 = space();
if (if_block5)
if_block5.c();
attr(div0, "class", "place fileThumb svelte-vw6znf");
attr(div0, "class", "place svelte-vw6znf");
toggle_class(div0, "contract", ctx[5]);
attr(div1, "class", "hoverer svelte-vw6znf");
toggle_class(div1, "visible", ctx[6] && ctx[5]);
@ -14747,8 +14748,8 @@
};
var textToElement = (s) => document.createRange().createContextualFragment(s).children[0];
var processPost = async (post) => {
const thumb = post.querySelector(".fileThumb");
const origlink = post.querySelector(".file-info > a");
const thumb = post.querySelector("a.fileThumb");
const origlink = post.querySelector('.file-info > a[target*="_blank"]');
if (!thumb || !origlink)
return;
const res2 = await processImage(origlink.href, (origlink.querySelector(".fnfull") || origlink).textContent || "");
@ -14762,18 +14763,23 @@
replyBox?.classList.add("hasembed");
const isCatalog = replyBox?.classList.contains("catalog-post");
if (!isCatalog) {
const ft = thumb;
const ahem = ft.querySelector(".place");
const imgcont = ahem || document.createElement("div");
const eyecont = ahem || document.createElement("span");
const p = thumb.parentElement;
if (!ahem) {
p.removeChild(thumb);
imgcont.appendChild(thumb);
const ft = post.querySelector("div.file");
const info = post.querySelector("span.file-info");
const filehost = ft.querySelector(".filehost");
const eyehost = info.querySelector(".eyehost");
const imgcont = filehost || document.createElement("div");
const eyecont = eyehost || document.createElement("span");
if (!filehost) {
ft.append(imgcont);
imgcont.classList.add("fileThumb");
replyBox?.querySelector("a[download]").insertAdjacentElement("afterend", eyecont);
imgcont.classList.add("filehost");
} else {
imgcont.innerHTML = "";
}
if (!eyehost) {
info.append(eyecont);
eyecont.classList.add("eyehost");
} else {
eyecont.innerHTML = "";
}
const id = ~~(Math.random() * 2e7);
@ -14791,8 +14797,6 @@
id: "" + id
}
});
if (!ahem)
p.appendChild(imgcont);
} else {
const opFile = post.querySelector(".catalog-link");
const ahem = opFile?.querySelector(".catalog-host");
@ -14827,7 +14831,7 @@
rec.addedNodes.forEach((e) => {
if (!(e instanceof HTMLElement))
return;
let el = e.querySelectorAll(".postContainer");
let el = e.querySelectorAll('.postContainer:not([class*="noFile"])');
if (!el && e.classList.contains("postContainer"))
el = e;
if (el)
@ -14837,7 +14841,7 @@
document.querySelectorAll(".board").forEach((e) => {
mo.observe(e, { childList: true, subtree: true });
});
const posts = [...document.querySelectorAll(".postContainer")];
const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')];
const scts = document.getElementById("shortcuts");
const button = textToElement(`<span></span>`);
const settingsButton = new SettingsButton_default({

2
src/Embedding.svelte

@ -195,7 +195,7 @@
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
<div
class:contract={contracted}
class="place fileThumb"
class="place"
on:click={() => bepis()}
on:mouseover={hoverStart}
on:mouseout={hoverStop}

4
src/global.css

@ -57,4 +57,8 @@ div.hasext .catalog-host img {
max-width: 80px;
max-height: 80px;
box-shadow: 0px 0px 4px 2px #00000090;
}
.fileThumb.filehost {
margin-left: 0 !important;
}

34
src/main.ts

@ -112,8 +112,8 @@ const textToElement = <T = HTMLElement>(s: string) =>
document.createRange().createContextualFragment(s).children[0] as any as T;
const processPost = async (post: HTMLDivElement) => {
const thumb = post.querySelector(".fileThumb") as HTMLAnchorElement;
const origlink = post.querySelector('.file-info > a') as HTMLAnchorElement;
const thumb = post.querySelector("a.fileThumb") as HTMLAnchorElement;
const origlink = post.querySelector('.file-info > a[target*="_blank"]') as HTMLAnchorElement;
if (!thumb || !origlink)
return;
const res2 = await processImage(origlink.href, (origlink.querySelector('.fnfull') || origlink).textContent || '');
@ -127,19 +127,25 @@ const processPost = async (post: HTMLDivElement) => {
const isCatalog = replyBox?.classList.contains('catalog-post');
// add buttons
if (!isCatalog) {
const ft = thumb;
const ahem: HTMLElement | null = ft.querySelector('.place');
const imgcont = ahem || document.createElement('div');
const eyecont = ahem || document.createElement('span');
const p = thumb.parentElement!;
const ft = post.querySelector('div.file') as HTMLDivElement;
const info = post.querySelector("span.file-info") as HTMLSpanElement;
const filehost: HTMLElement | null = ft.querySelector('.filehost');
const eyehost: HTMLElement | null = info.querySelector('.eyehost');
const imgcont = filehost || document.createElement('div');
const eyecont = eyehost || document.createElement('span');
if (!ahem) {
p.removeChild(thumb);
imgcont.appendChild(thumb);
if (!filehost) {
ft.append(imgcont);
imgcont.classList.add("fileThumb");
replyBox?.querySelector('a[download]')!.insertAdjacentElement("afterend", eyecont);
imgcont.classList.add("filehost");
} else {
imgcont.innerHTML = '';
}
if (!eyehost) {
info.append(eyecont);
eyecont.classList.add("eyehost");
} else {
eyecont.innerHTML = '';
}
const id = ~~(Math.random() * 20000000);
@ -157,8 +163,6 @@ const processPost = async (post: HTMLDivElement) => {
id: '' + id
}
});
if (!ahem)
p.appendChild(imgcont);
} else {
const opFile = post.querySelector('.catalog-link');
const ahem = opFile?.querySelector('.catalog-host');
@ -201,7 +205,7 @@ const startup = async () => {
if (!(e instanceof HTMLElement))
return;
// apparently querySelector cannot select the root element if it matches
let el = (e as any).querySelectorAll(".postContainer");
let el = (e as any).querySelectorAll('.postContainer:not([class*="noFile"])');
if (!el && e.classList.contains('postContainer'))
el = e;
if (el)
@ -212,7 +216,7 @@ const startup = async () => {
document.querySelectorAll('.board').forEach(e => {
mo.observe(e!, { childList: true, subtree: true });
});
const posts = [...document.querySelectorAll('.postContainer')];
const posts = [...document.querySelectorAll('.postContainer:not([class*="noFile"])')];
const scts = document.getElementById('shortcuts');
const button = textToElement(`<span></span>`);

Loading…
Cancel
Save