mirror of
https://github.com/osnr/TabFS.git
synced 2024-05-06 23:56:33 +02:00
extension: red highlights for routes.
This commit is contained in:
parent
73f4672a8c
commit
345c7a4af5
|
@ -538,9 +538,35 @@ Router["/runtime/reload"] = {
|
||||||
};
|
};
|
||||||
Router["/runtime/background.js.html"] = defineFile(async () => {
|
Router["/runtime/background.js.html"] = defineFile(async () => {
|
||||||
const js = await window.fetch(chrome.runtime.getURL('background.js'))
|
const js = await window.fetch(chrome.runtime.getURL('background.js'))
|
||||||
.then(r => r.text());
|
.then(r => r.text());
|
||||||
|
|
||||||
|
const classes = [
|
||||||
|
[/Router\["[^\]]+"\] = /, 'route']
|
||||||
|
];
|
||||||
|
|
||||||
|
const classedJs =
|
||||||
|
js.split('\n')
|
||||||
|
.map(line => {
|
||||||
|
const class_ = classes.find(([re, class_]) => re.test(line));
|
||||||
|
line = line
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, """)
|
||||||
|
.replace(/'/g, "'");
|
||||||
|
if (!class_) { return `<span>${line}</span>`; }
|
||||||
|
return `<span class="${class_[1]}">${line}</span>`;
|
||||||
|
})
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
.route { background-color: red; }
|
||||||
|
span:not(.route) { height: 0px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<dl>
|
<dl>
|
||||||
${Object.entries(Router).map(([a, b]) => `
|
${Object.entries(Router).map(([a, b]) => `
|
||||||
|
@ -548,7 +574,7 @@ Router["/runtime/background.js.html"] = defineFile(async () => {
|
||||||
<dd>${b}</dd>
|
<dd>${b}</dd>
|
||||||
`).join('\n')}
|
`).join('\n')}
|
||||||
</dl>
|
</dl>
|
||||||
<pre><code>${js}</code></pre>
|
<pre><code>${classedJs}</code></pre>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
|
|
Loading…
Reference in a new issue