Fix #5291: use local storage to store :reader pages

This commit is contained in:
Oliver Blanthorn 2025-11-23 20:24:36 +01:00
parent 3f9a19243f
commit c15f0c9003
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 9 additions and 4 deletions

View file

@ -99,6 +99,7 @@ import * as Proxy from "@src/lib/proxy"
import * as arg from "@src/lib/arg_util"
import * as R from "ramda"
import * as treestyletab from "@src/interop/tst"
import { uuidv4 } from "@src/lib/math"
/**
* This is used to drive some excmd handling in `composite`.
@ -6229,7 +6230,10 @@ export async function readerurl() {
const article = new Readability(document.cloneNode(true) as any as Document).parse()
article["link"] = window.location.href
article["favicon"] = (await ownTab()).favIconUrl
return browser.runtime.getURL("static/reader.html#" + btoa(encodeURIComponent(JSON.stringify(article))))
const article_encoded = btoa(encodeURIComponent(JSON.stringify(article)))
const article_uuid = uuidv4()
await set("reader_articles." + article_uuid, article_encoded)
return browser.runtime.getURL("static/reader.html#" + article_uuid)
}
/**

View file

@ -1,10 +1,11 @@
import * as config from "@src/lib/config"
import xss from "xss"
import { isuuidv4 } from "@src/lib/math"
async function updatePage() {
const article = JSON.parse(
decodeURIComponent(atob(window.location.hash.substr(1))),
)
const hash = window.location.hash.substr(1)
const isuuid = isuuidv4(hash)
const article = JSON.parse(decodeURIComponent(atob(isuuid ? await config.getAsync("reader_articles", hash) : hash)))
article.content = xss(article.content, { stripIgnoreTag: true })
const content = document.createElement("main")
content.innerHTML = article.content