diff --git a/src/main.js b/src/main.js index 51f9ef6..27e1583 100644 --- a/src/main.js +++ b/src/main.js @@ -18,6 +18,7 @@ const STANDARD_HEADERS = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36", }; +const MARK = ["", "")) { + let trimmedRead = read.trimStart(); + let valid = MARK.find(mark => trimmedRead.startsWith(mark)); + if (!valid) { controller.abort(); CUSTOM_LOG( ":endpoint not standard HTML, aborting", diff --git a/src/renderer.js b/src/renderer.js index 88ee97a..26ee6dd 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -142,18 +142,18 @@ function patchCSS() { document.querySelector("html > head").appendChild(cssPatch); } -const FETCHING = new Set(); +let fetching = new Set(); let cacheMap = new Map(); async function loadPreview(url, container) { let id = await sha1(url); let nullableResult = cacheMap.get(id); if (!nullableResult) { - if (FETCHING.has(id)) { + if (fetching.has(id)) { return; } - FETCHING.add(id); + fetching.add(id); let turn = await window.link_preview.bakePreview(url); - FETCHING.delete(id); + fetching.delete(id); turn._url = new URL(url); if (!turn.error) { turn.result = extractContent(htmlParser(turn.result)); @@ -181,11 +181,17 @@ async function loadPreview(url, container) { // nullableResult.result // ); // } - debounce(render(container, nullableResult), 100); + render(container, nullableResult); } } onLoad(); +// todo: debug +// Object.defineProperty(window, "lpDebug", { +// value: cacheMap, +// writable: false +// }); + async function onLoad() { const observer = new MutationObserver(async (mutationsList) => { for (let mutation of mutationsList) {