mirror of
https://git.coom.tech/fuckjannies/lolipiss.git
synced 2024-06-29 05:52:35 +00:00
Fix file change detection on native extension
This commit is contained in:
parent
c78cb5f3ca
commit
ed8d679e6d
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name PNGExtraEmbed
|
// @name PNGExtraEmbed
|
||||||
// @namespace https://coom.tech/
|
// @namespace https://coom.tech/
|
||||||
// @version 0.186
|
// @version 0.187
|
||||||
// @description uhh
|
// @description uhh
|
||||||
// @author You
|
// @author You
|
||||||
// @match https://boards.4channel.org/*
|
// @match https://boards.4channel.org/*
|
||||||
|
|
23
main.user.js
23
main.user.js
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name PNGExtraEmbed
|
// @name PNGExtraEmbed
|
||||||
// @namespace https://coom.tech/
|
// @namespace https://coom.tech/
|
||||||
// @version 0.186
|
// @version 0.187
|
||||||
// @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, 186];
|
define_BUILD_VERSION_default = [0, 187];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -28012,23 +28012,26 @@
|
||||||
target: a,
|
target: a,
|
||||||
props: { processors, textinput: (e.detail || e.target).querySelector("textarea") }
|
props: { processors, textinput: (e.detail || e.target).querySelector("textarea") }
|
||||||
});
|
});
|
||||||
|
let prevFile;
|
||||||
let target;
|
let target;
|
||||||
|
const somethingChanged = async (m) => {
|
||||||
|
const currentFile = await getSelectedFile();
|
||||||
|
if (prevFile != currentFile) {
|
||||||
|
prevFile = currentFile;
|
||||||
|
document.dispatchEvent(new CustomEvent("PEEFile", { detail: prevFile }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const obs = new MutationObserver(somethingChanged);
|
||||||
if (!cappState.is4chanX) {
|
if (!cappState.is4chanX) {
|
||||||
target = e.detail;
|
target = e.detail;
|
||||||
a.style.display = "inline-block";
|
a.style.display = "inline-block";
|
||||||
target.querySelector("input[type=submit]")?.insertAdjacentElement("beforebegin", a);
|
target.querySelector("input[type=submit]")?.insertAdjacentElement("beforebegin", a);
|
||||||
|
const filesinp = target.querySelector("#qrFile");
|
||||||
|
filesinp.addEventListener("change", somethingChanged);
|
||||||
} else {
|
} else {
|
||||||
target = e.target;
|
target = e.target;
|
||||||
target.querySelector("#qr-filename-container")?.appendChild(a);
|
target.querySelector("#qr-filename-container")?.appendChild(a);
|
||||||
const filesinp = target.querySelector("#file-n-submit");
|
const filesinp = target.querySelector("#file-n-submit");
|
||||||
let prevFile;
|
|
||||||
const obs = new MutationObserver(async (m) => {
|
|
||||||
const currentFile = await getSelectedFile();
|
|
||||||
if (prevFile != currentFile) {
|
|
||||||
prevFile = currentFile;
|
|
||||||
document.dispatchEvent(new CustomEvent("PEEFile", { detail: prevFile }));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
obs.observe(filesinp, { attributes: true });
|
obs.observe(filesinp, { attributes: true });
|
||||||
}
|
}
|
||||||
}, { once: !cappState.is4chanX });
|
}, { once: !cappState.is4chanX });
|
||||||
|
|
23
src/main.ts
23
src/main.ts
|
@ -463,26 +463,29 @@ document.addEventListener('QRDialogCreation', <any>((e: CustomEvent<HTMLElement>
|
||||||
target: a,
|
target: a,
|
||||||
props: { processors, textinput: (e.detail || e.target).querySelector('textarea')! }
|
props: { processors, textinput: (e.detail || e.target).querySelector('textarea')! }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let prevFile: File;
|
||||||
let target;
|
let target;
|
||||||
|
const somethingChanged = async (m: any) => {
|
||||||
|
// file possibly changed
|
||||||
|
const currentFile = await getSelectedFile();
|
||||||
|
if (prevFile != currentFile) {
|
||||||
|
prevFile = currentFile;
|
||||||
|
document.dispatchEvent(new CustomEvent("PEEFile", { detail: prevFile }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const obs = new MutationObserver(somethingChanged);
|
||||||
if (!cappState.is4chanX) {
|
if (!cappState.is4chanX) {
|
||||||
target = e.detail;
|
target = e.detail;
|
||||||
a.style.display = "inline-block";
|
a.style.display = "inline-block";
|
||||||
target.querySelector("input[type=submit]")?.insertAdjacentElement("beforebegin", a);
|
target.querySelector("input[type=submit]")?.insertAdjacentElement("beforebegin", a);
|
||||||
|
const filesinp = target.querySelector('#qrFile') as HTMLInputElement;
|
||||||
|
filesinp.addEventListener("change", somethingChanged);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
target = e.target as HTMLDivElement;
|
target = e.target as HTMLDivElement;
|
||||||
target.querySelector('#qr-filename-container')?.appendChild(a);
|
target.querySelector('#qr-filename-container')?.appendChild(a);
|
||||||
const filesinp = target.querySelector('#file-n-submit') as HTMLInputElement;
|
const filesinp = target.querySelector('#file-n-submit') as HTMLInputElement;
|
||||||
let prevFile: File;
|
|
||||||
const obs = new MutationObserver(async (m) => {
|
|
||||||
// file possibly changed
|
|
||||||
const currentFile = await getSelectedFile();
|
|
||||||
if (prevFile != currentFile) {
|
|
||||||
prevFile = currentFile;
|
|
||||||
document.dispatchEvent(new CustomEvent("PEEFile", { detail: prevFile }));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
obs.observe(filesinp, { attributes: true });
|
obs.observe(filesinp, { attributes: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user