Skip to content

Manage nojs and js entries

David-Apps edited this page Jul 18, 2022 · 1 revision

You can disable JavaScript for URLs that match a pattern by using the nojs keyword in your configuration file. You can override this (and so enable JavaScript) for URLs that match a pattern by using the js keyword in your configuration file. Suppose that your configuration file contains the entries: nojs = com js = example.com This would disable JavaScript for URLs that match the com pattern, unless the URLs match the example.com pattern.

Your configuration file can have many nojs and js entries, each for a separate URL pattern. You can use these functions to help you manage these entries. The nojs function adds a nojs entry if the entry does not already exist. The js function adds a js entry if the entry does not already exist. The lsnojs function lists the nojs entries. The lsjs function lists the js entries. The rmnojs function removes the nojs entries. The rmjs function removes the js entries. You must give the nojs and js functions an argument for the URL pattern that you want to add an entry for. You can give the lsnojs, lsjs, rmnojs, and rmjs functions an argument to list or remove entries that match the argument.

# Add nojs entry to configuration file.
# usage: <nojs <url pattern
function+nojs {
db0
e -c
g/^\s*nojs\s*=\s*~1\s*$/X
if(?) {
?^\s*nojs\s*=?X
s/$/\nnojs = ~1/
w
config
}
^
}

# Add js entry to configuration file.
# usage: <js <url pattern
function+js {
db0
H-
sw+
e -c
g/^\s*js\s*=\s*~1\s*$/X
if(?) {
/^\s*nojs\s*=/X
s/^/js = ~1\n/
w
config
}
^
}

# List nojs entries in configuration file.
# usage: <lsnojs <url pattern>
function+lsnojs {
db0
e -c
g/^\s*nojs\s*=\s*~0/
if(?) {
}
^
}

# List js entries in configuration file.
# usage: <lsjs <url pattern>
function+lsjs {
db0
e -c
g/^\s*js\s*=\s*~0/
if(?) {
}
^
}

# Remove nojs entry from configuration file.
# usage: <rmnojs <url pattern>
function+rmnojs {
db0
e -c
g/^\s*nojs\s*=\s*~0/d
if(*) {
w
config
}
^
}

# Remove js entry from configuration file.
# usage: <rmjs <url pattern>
function+rmjs {
db0
e -c
g/^\s*js\s*=\s*~0/d
if(*) {
w
config
}
^
}