~pvsr/dotfiles

ref: f2253ff80bf5399b4d19f6b2191a536f5ee8bf8c dotfiles/qutebrowser/bin/allowjs -rwxr-xr-x 581 bytes
f2253ff8Peter Rice fix xdg bug in allowjs 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env fish
argparse -N 1 -X 1 'd/domain=' -- $argv

if set -q _flag_domain
    set domains $_flag_domain
else
    set config_home (set -q XDG_CONFIG_HOME; and echo $XDG_CONFIG_HOME; or echo $HOME/.config)
    set domains $config_home/qutebrowser/conf.d/domains
end

set backup (mktemp -t domains.XXXXXXXXXX)
and cp $domains $backup
or begin
    echo 'failed to create backup'
    exit 1
end

cat $domains (string split ' ' $argv | sed -e 's|^|*://|' -e 's|$|/*|' | psub) | sort -u -o $domains
or begin
    echo 'failed to modify the whitelist'
    cp $backup $domains
end