Fix outer page things not getting cached

This commit is contained in:
Hamcha 2020-06-21 19:29:57 +02:00
parent df914edcb5
commit e700bb9c30
Signed by untrusted user: hamcha
GPG key ID: 41467804B19A3315
2 changed files with 6 additions and 6 deletions

View file

@ -59,12 +59,12 @@ async function loadPage(page: string, elem: HTMLElement) {
processHTML(elem, page); processHTML(elem, page);
// Save result to cache // Save result to cache
cache.set(key, elem.innerHTML, CURRENT_VERSION).then(() => { cache.set(key, elem.outerHTML, CURRENT_VERSION).then(() => {
console.log(`${page}: saved to cache`); console.log(`${page}: saved to cache`);
}); });
} else { } else {
// Set cached content as HTML // Set cached content as HTML
elem.innerHTML = html; elem.outerHTML = html;
} }
bindFunctions(elem, page); bindFunctions(elem, page);

View file

@ -4,9 +4,12 @@ import { findParent } from "./utils";
// This is used for cache busting when userscript changes significantly. // This is used for cache busting when userscript changes significantly.
// Only change it when you made changes to the processHTML part! // Only change it when you made changes to the processHTML part!
export const CURRENT_VERSION = "7930f961710641f022ef0cd3ad3277ffd4eab7eb"; export const CURRENT_VERSION = "df914edcb5522670309ceb8dfd0195dc70fb81d4";
function chemistryFixups(root: HTMLElement) { function chemistryFixups(root: HTMLElement) {
// Enable page-specific CSS rules
root.classList.add("bchem");
// Fix inconsistencies with <p> on random parts // Fix inconsistencies with <p> on random parts
// Ideally I'd like a <p> or something on every part, wrapping it completely, but for now let's just kill 'em // Ideally I'd like a <p> or something on every part, wrapping it completely, but for now let's just kill 'em
root root
@ -135,9 +138,6 @@ function chemistryFixups(root: HTMLElement) {
if (overdose) overdose.parentElement.removeChild(overdose); if (overdose) overdose.parentElement.removeChild(overdose);
if (addiction) addiction.parentElement.removeChild(addiction); if (addiction) addiction.parentElement.removeChild(addiction);
}); });
// Enable page-specific CSS rules
root.classList.add("bchem");
} }
export function processHTML(root: HTMLElement, docname: string): void { export function processHTML(root: HTMLElement, docname: string): void {