Skip to content
David-Apps edited this page Mar 5, 2023 · 1 revision

This function removes some of the clutter from an HTML page.

# Remove clutter.
# usage: <focus
function:focus {
db0
H-
sw+
ub
# Set the hidden attribute on aside elements.
,s/<aside/& hidden/g
# Try to delete the contents of the body element that is outside the main element.
$X
/<body/s/<body[^>]*>/\n&\n/
$X
/<main/s/<main/\n&/
$X
/<body/X
if(*) {
+,/<main/-d
}
1X
/<\/main>/s/<\/main>/\n&\n/
1X
?</body>?s/<\/body>/\n&\n/$
1X
/<\/main>/X
if(*) {
+,?</body>?-d
}
b
}