mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Fix #5291: use local storage to store :reader pages
This commit is contained in:
parent
3f9a19243f
commit
c15f0c9003
|
|
@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue