Public: Hide <link rel="me"> head tags from appearing in the source

This patch adds some dirty line iteration and regexes to remove <link>
tags from the documents that would clutter the head section of the
document and as such make content harder to read.
This commit is contained in:
networkException 2022-12-18 21:09:13 +01:00
parent 8ed993d7d2
commit d5ef5aa149
Signed by: networkException
GPG key ID: E3877443AE684391
2 changed files with 14 additions and 2 deletions

View file

@ -100,7 +100,13 @@
import { Inspector } from '/script/html/inspector.js';
const response = await fetch(window.location.href);
const text = await response.text();
const text = (await response.text())
// NOTE: This removes <link rel="me" href="some-ressource"> tags from the document so the head
// doesn't get as cluttered.
// FIXME: Change this to use a more sophisticated api once tree construction is implemented.
.split('\n')
.filter(line => line.match(/^(?:\s*)<link rel="me" href="(.*)">/) === null)
.join('\n');
window.tokens = tokenize(normalizeNewlines(text));
window.spans = highlight(tokens);

View file

@ -101,7 +101,13 @@
const request = new XMLHttpRequest();
request.addEventListener("load", async function() {
const text = this.responseText;
const text = this.responseText
// NOTE: This removes <link rel="me" href="some-ressource"> tags from the document so the head
// doesn't get as cluttered.
// FIXME: Change this to use a more sophisticated api once tree construction is implemented.
.split('\n')
.filter(line => line.match(/^(?:\s*)<link rel="me" href="(.*)">/) === null)
.join('\n');
window.tokens = tokenize(normalizeNewlines(text));
window.spans = highlight(tokens);