This commit is contained in:
Jack Mahoney 2026-01-07 16:36:00 -08:00 committed by GitHub
commit a9798935ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 21 deletions

View File

@ -75,8 +75,6 @@ The following userscripts can be found on their own repositories.
and retrieve they when you want. and retrieve they when you want.
- [doi](https://github.com/cadadr/configuration/blob/default/dotfiles/qutebrowser/userscripts/doi): - [doi](https://github.com/cadadr/configuration/blob/default/dotfiles/qutebrowser/userscripts/doi):
Opens DOIs on Sci-Hub. Opens DOIs on Sci-Hub.
- [qute-1password](https://github.com/fmartingr/qute-1password):
Qutebrowser userscript to fill 1password credentials
- [1password](https://github.com/tomoakley/dotfiles/blob/master/qutebrowser/userscripts/1password): - [1password](https://github.com/tomoakley/dotfiles/blob/master/qutebrowser/userscripts/1password):
Integration with 1password on macOS. Integration with 1password on macOS.
- [localhost](https://github.com/SidharthArya/.qutebrowser/blob/master/userscripts/localhost): - [localhost](https://github.com/SidharthArya/.qutebrowser/blob/master/userscripts/localhost):
@ -97,7 +95,7 @@ The following userscripts can be found on their own repositories.
substitution) substitution)
- [pseudo per domain stylesheets](https://github.com/bschnitz/qute): Userscript - [pseudo per domain stylesheets](https://github.com/bschnitz/qute): Userscript
for generating url restricted greasemonkey scripts to apply user styles. for generating url restricted greasemonkey scripts to apply user styles.
- [qute-containers](https://github.com/s-praveen-kumar/qute-containers): - [qute-containers](https://github.com/s-praveen-kumar/qute-containers):
A simple interface to manage browser containers by manipulating the basedir A simple interface to manage browser containers by manipulating the basedir
parameter. parameter.
- [qutebrowser-metascript](https://codeberg.org/mister_monster/qutebrowser-metascript): - [qutebrowser-metascript](https://codeberg.org/mister_monster/qutebrowser-metascript):
@ -108,7 +106,7 @@ The following userscripts can be found on their own repositories.
automatically mutates input URLs based on configurable rules automatically mutates input URLs based on configurable rules
- [qute-translate-popup](https://github.com/JohnBardoe/qute-translate-popup): - [qute-translate-popup](https://github.com/JohnBardoe/qute-translate-popup):
selected text translation, with a qute popup! selected text translation, with a qute popup!
[Zotero]: https://www.zotero.org/ [Zotero]: https://www.zotero.org/
[Pocket]: https://getpocket.com/ [Pocket]: https://getpocket.com/
[Instapaper]: https://www.instapaper.com/ [Instapaper]: https://www.instapaper.com/

View File

@ -70,48 +70,57 @@ echo "message-info 'Looking for password for $URL...'" >> "$QUTE_FIFO"
if [ -f "$TOKEN_CACHE" ]; then if [ -f "$TOKEN_CACHE" ]; then
TOKEN=$(cat "$TOKEN_CACHE") TOKEN=$(cat "$TOKEN_CACHE")
if ! op signin --session="$TOKEN" --output=raw > /dev/null; then if ! op signin --session="$TOKEN" --raw > /dev/null; then
TOKEN=$(rofi -dmenu -password -p "1password: "| op signin --output=raw) || TOKEN="" TOKEN=$(rofi -dmenu -password -p "1password: " | op signin --raw) || TOKEN=""
echo "$TOKEN" > "$TOKEN_CACHE" echo "$TOKEN" > "$TOKEN_CACHE"
fi fi
else else
TOKEN=$(rofi -dmenu -password -p "1password: "| op signin --output=raw) || TOKEN="" TOKEN=$(rofi -dmenu -password -p "1password: " | op signin --raw) || TOKEN=""
install -m 600 /dev/null "$TOKEN_CACHE" install -m 600 /dev/null "$TOKEN_CACHE"
echo "$TOKEN" > "$TOKEN_CACHE" echo "$TOKEN" > "$TOKEN_CACHE"
fi fi
if [ -n "$TOKEN" ]; then if [ -n "$TOKEN" ]; then
UUID=$(op list items --cache --session="$TOKEN" | jq --arg url "$URL" -r '[.[] | {uuid, url: [.overview.URLs[]?.u, .overview.url][]?} | select(.uuid != null) | select(.url != null) | select(.url|test(".*\($url).*"))][.0].uuid') || UUID="" # find entry matching the exact host of our domain
UUID=$(op item list --format=json --session="$TOKEN" | \
jq --arg url "$URL" -r '
[ .[]
| select((.urls[]?.href // .url? // "")
| split("/")[2] == $url)
| .id
]
| first
') || UUID=""
if [ -z "$UUID" ] || [ "$UUID" == "null" ];then if [ -z "$UUID" ] || [ "$UUID" == "null" ]; then
echo "message-error 'No entry found for $URL'" >> "$QUTE_FIFO" TITLE=$(op item list --format=json --session="$TOKEN" | jq -r '.[].title' | rofi -dmenu -i) || TITLE=""
TITLE=$(op list items --cache --session="$TOKEN" | jq -r '.[].overview.title' | rofi -dmenu -i) || TITLE=""
if [ -n "$TITLE" ]; then if [ -n "$TITLE" ]; then
UUID=$(op list items --cache --session="$TOKEN" | jq --arg title "$TITLE" -r '[.[] | {uuid, title:.overview.title}|select(.title|test("\($title)"))][.0].uuid') || UUID="" # fallback: pick entry whose title contains the chosen string
else UUID=$(op item list --format=json --session="$TOKEN" | \
UUID="" jq --arg title "$TITLE" -r '[.[] | select(.title | contains($title))][0].id') || UUID=""
fi fi
fi fi
if [ -n "$UUID" ];then if [ -n "$UUID" ]; then
ITEM=$(op get item --cache --session="$TOKEN" "$UUID") ITEM=$(op item get --format=json --session="$TOKEN" "$UUID")
PASSWORD=$(echo "$ITEM" | jq -r '.details.fields | .[] | select(.designation=="password") | .value') # extract password field (fallback to any concealed field if purpose missing)
PASSWORD=$(echo "$ITEM" | jq -r '(.fields[] | select(.purpose=="PASSWORD") | .value) // (.fields[] | select(.type=="CONCEALED") | .value)' | head -n1)
if [ -n "$PASSWORD" ]; then if [ -n "$PASSWORD" ]; then
TITLE=$(echo "$ITEM" | jq -r '.overview.title') TITLE=$(echo "$ITEM" | jq -r '.title')
USERNAME=$(echo "$ITEM" | jq -r '.details.fields | .[] | select(.designation=="username") | .value') USERNAME=$(echo "$ITEM" | jq -r '.fields[] | select(.purpose=="USERNAME") | .value')
printjs() { printjs() {
js | sed 's,//.*$,,' | tr '\n' ' ' js | sed 's,//.*$,,' | tr '\n' ' '
} }
echo "jseval -q $(printjs)" >> "$QUTE_FIFO" echo "jseval -q $(printjs)" >> "$QUTE_FIFO"
TOTP=$(echo "$ITEM" | op get totp --cache --session="$TOKEN" "$UUID") || TOTP="" TOTP=$(op item get --otp --session="$TOKEN" "$UUID") || TOTP=""
if [ -n "$TOTP" ]; then if [ -n "$TOTP" ]; then
echo "$TOTP" | xclip -in -selection clipboard echo "$TOTP" | xclip -in -selection clipboard
echo "message-info 'Pasted one time password for $TITLE to clipboard'" >> "$QUTE_FIFO" echo "message-info 'Pasted one time password for $TITLE to clipboard'" >> "$QUTE_FIFO"
fi fi
else else
echo "message-error 'No password found for $URL'" >> "$QUTE_FIFO" echo "message-error 'No password found for $URL'" >> "$QUTE_FIFO"
@ -122,3 +131,4 @@ if [ -n "$TOKEN" ]; then
else else
echo "message-error 'Wrong master password'" >> "$QUTE_FIFO" echo "message-error 'Wrong master password'" >> "$QUTE_FIFO"
fi fi