WIP: make back button work

Command line is very broken. Generally thinking this might
be a bad idea because it feels like it would be fragile,
needing updating every time we add something to Tridactyl
This commit is contained in:
Oliver Blanthorn 2023-04-05 18:48:55 +02:00
parent 02e11b321e
commit 569b01a607
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -5991,6 +5991,10 @@ import { Readability } from "@mozilla/readability"
//#content //#content
export async function reader2() { export async function reader2() {
// Store old doc for restoration
const old_doc = document.documentElement.innerHTML
const cmdline = document.getElementById("cmdline_iframe")
document.querySelectorAll(".TridactylStatusIndicator").forEach(ind => ind.parentNode.removeChild(ind)) document.querySelectorAll(".TridactylStatusIndicator").forEach(ind => ind.parentNode.removeChild(ind))
const article = new Readability(document).parse() const article = new Readability(document).parse()
document.body.innerHTML = article.content document.body.innerHTML = article.content
@ -6021,6 +6025,15 @@ export async function reader2() {
} }
document.body.insertBefore(header, document.body.firstChild) document.body.insertBefore(header, document.body.firstChild)
} }
window.history.pushState(null, null)
const old_pop = window.onpopstate
window.onpopstate = () => {
document.documentElement.innerHTML = old_doc
document.documentElement.appendChild(cmdline)
window.onpopstate = old_pop
}
} }
/** /**