Refactoring to use DocRewriter.

This commit is contained in:
hackademix 2024-10-30 09:26:59 +01:00
parent 68fbf0dded
commit 2d9835591d
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
3 changed files with 5 additions and 6 deletions

View File

@ -18,6 +18,8 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
// depends on /nscl/content/DocRewriter.js
"use strict";
(window.ns || (window.ns = {})).syncFetchPolicy = function() {
@ -116,7 +118,6 @@
try {
debug("Soft reload", ev); // DEV_ONLY
try {
let doc = window.wrappedJSObject.document;
let isDir = document.querySelector("link[rel=stylesheet][href^='chrome:']")
&& document.querySelector(`base[href^="${url}"]`);
if (isDir || document.contentType !== "text/html") {
@ -127,10 +128,7 @@
let html = document.documentElement.outerHTML;
let sx = window.scrollX, sy = window.scrollY;
doc.open();
console.debug("Opened", doc.documentElement);
doc.write(html);
doc.close();
DocRewriter.rewrite(html);
debug("Written", html);
// Work-around this rendering bug: https://forums.informaction.com/viewtopic.php?p=103105#p103050
debug("Scrolling back to", sx, sy);

View File

@ -94,6 +94,7 @@
"/nscl/common/CSP.js",
"/nscl/common/CapsCSP.js",
"/nscl/common/RequestKey.js",
"/nscl/content/DocRewriter.js",
"/nscl/content/patchWindow.js",
"/nscl/content/patchWorkers.js",
"/nscl/content/DocumentCSP.js",

@ -1 +1 @@
Subproject commit 9705b11ac271b44c70fc086a162326a83c0b2dbe
Subproject commit 3aff8f5c9820437c52dedaeaa0b73631eecbfeee