aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/load_cookies.sh
blob: 5feca05523676ee3eca2b965ab06e2e51f2e0d6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

if [ -n "$1" ]; then
    cookie_file="$1"
    shift
else
    cookie_file="${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/cookies.txt"
fi

awk -F \\t '
BEGIN {
    scheme["TRUE"] = "https";
    scheme["FALSE"] = "http";
}
$0 ~ /^#HttpOnly_/ {
    gsub(/@/, "\\@")
    printf("add_cookie \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n", substr($1,length("#HttpOnly_")+1,length($1)), $3, $6, $7, scheme[$4], $5)
}
$0 !~ /^#/ {
    gsub(/@/, "\\@")
    printf("add_cookie \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n", $1, $3, $6, $7, scheme[$4], $5)
}
' "$cookie_file"