From 975ade186cae1d37d1203afb5e181b46734d95d5 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 12 Jan 2022 22:46:54 -0500 Subject: Add LWN to sup --- bin/man1/sup.1 | 3 ++- bin/sup.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/bin/man1/sup.1 b/bin/man1/sup.1 index 7f84f11b..bd88ad47 100644 --- a/bin/man1/sup.1 +++ b/bin/man1/sup.1 @@ -1,4 +1,4 @@ -.Dd January 9, 2022 +.Dd January 12, 2022 .Dt SUP 1 .Os . @@ -34,6 +34,7 @@ The following services are supported: .Cm freebsdbugzilla , .Cm liberapay , .Cm lobsters , +.Cm lwn , .Cm patreon , .Cm tildegit , .Cm tildenews . diff --git a/bin/sup.sh b/bin/sup.sh index ae369e36..32e282d1 100644 --- a/bin/sup.sh +++ b/bin/sup.sh @@ -203,6 +203,34 @@ lobsters() { open "${lobstersBase}/login" } +lwn() { + username=$email + echo 'Submitting form...' + curl -Ss -X POST -F "username=${username}" \ + 'https://lwn.net/Login/MailPWLink' \ + >/dev/null + echo 'Waiting for email...' + key=$( + git fetch-email -i -M Trash \ + -F 'lwn@lwn.net' -S 'A link to set your LWN.net password' | + sed -n 's|.*/Login/SetPassword/.*/\(.*\)|\1|p' + ) + echo 'Retrieving UID...' + uid=$( + curl -Ss "https://lwn.net/Login/SetPassword/${username}/${key}" | + sed -n 's/.*name="uid" value="\([^"]*\)".*/\1/p' + ) + password=$(generate) + echo 'Setting password...' + curl -Ss -X POST \ + -F "uid=${uid}" -F "key=${key}" \ + -F "new1=${password}" -F "new2=${password}" \ + 'https://lwn.net/Login/DoSetPassword' \ + >/dev/null + copy "${password}" + open 'https://lwn.net/Login/' +} + patreon() { readonly patreonAPI='https://www.patreon.com/api' echo 'Submitting form...' -- cgit 1.4.1