Changes
This commit is contained in:
67
local/share/qutebrowser/userscripts/copy-bookmark
Executable file
67
local/share/qutebrowser/userscripts/copy-bookmark
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# copy-bookmark
|
||||
# copies links to specific headers/elements of a page
|
||||
# by Dakedres
|
||||
#
|
||||
# I guessed at how Python works.
|
||||
# Based on https://github.com/LaurenceWarne/qute-code-hint/blob/master/code_select.py
|
||||
|
||||
# It is recommended you add this to your config.py to use this script:
|
||||
# c.hints.selectors["bookmarks"] = [
|
||||
# "h1[id]",
|
||||
# "h2[id]",
|
||||
# "h3[id]",
|
||||
# "h4[id]",
|
||||
# "h5[id]",
|
||||
# "h6[id]",
|
||||
# "h1 > a[id]",
|
||||
# "h2 > a[id]",
|
||||
# "h3 > a[id]",
|
||||
# "h4 > a[id]",
|
||||
# "h5 > a[id]",
|
||||
# "h6 > a[id]",
|
||||
# "header[id]",
|
||||
# "footer[id]",
|
||||
# "article[id]",
|
||||
# "section[id]",
|
||||
# "p[id]",
|
||||
# "div[itemtype=\"https://schema.org/Answer\"]" # Stackoverflow answers
|
||||
# ]
|
||||
# And call it with
|
||||
# hint bookmarks userscript copy-bookmark
|
||||
|
||||
import os
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
from html.parser import HTMLParser
|
||||
|
||||
class BookmarkParser(HTMLParser):
|
||||
def handle_starttag(self, tag, attrs):
|
||||
for attr in attrs:
|
||||
print(attr[0])
|
||||
if(attr[0] == "id"):
|
||||
self.bookmark_id = attr[1]
|
||||
|
||||
def close(self):
|
||||
HTMLParser.close(self)
|
||||
return self.bookmark_id
|
||||
|
||||
def send_to_qute(command):
|
||||
with open(os.environ.get("QUTE_FIFO"), "w") as f:
|
||||
f.write(command)
|
||||
|
||||
def construct_bookmark_url():
|
||||
parser = BookmarkParser()
|
||||
parser.feed(os.environ.get("QUTE_SELECTED_HTML"))
|
||||
bookmark_id = parser.close()
|
||||
|
||||
url = urlparse(os.environ.get("QUTE_CURRENT_URL") )
|
||||
url = url._replace(fragment=bookmark_id)
|
||||
|
||||
return urlunparse(url)
|
||||
|
||||
def main():
|
||||
send_to_qute("yank inline '{url}'".format(url=construct_bookmark_url() ) )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
47
local/share/qutebrowser/userscripts/le-password
Executable file
47
local/share/qutebrowser/userscripts/le-password
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
|
||||
mode=$1
|
||||
index=0
|
||||
|
||||
if [ -z "$mode" ]; then
|
||||
mode="eval"
|
||||
fi
|
||||
|
||||
printf %s\\n 'message-info "Requesting password..."' >> "$QUTE_FIFO"
|
||||
results=$(bw list items --session --url "$QUTE_CURRENT_URL")
|
||||
|
||||
query() {
|
||||
printf %s "$results" | jq "$1"
|
||||
}
|
||||
|
||||
if [ "$(query length)" != 1 ]; then
|
||||
index=$(query ".[] | .name,.login.username" | tr -d '"' | awk '!(NR%2){print $0 " (" p ")"}{p=$0}' | rofi -dmenu -format i)
|
||||
fi
|
||||
|
||||
password="$(query ".[${index}].login.password" | tr -d '"')"
|
||||
|
||||
case $mode in
|
||||
eval)
|
||||
username="$(query ".[${index}].login.username" | tr -d '"')"
|
||||
script=$(printf %s """\
|
||||
let e = document.activeElement, \
|
||||
f = e.closest('form'), \
|
||||
p = !f || e.type === 'password' ? e : f.querySelector('input[type=password]'), \
|
||||
u = !f || e.type === 'email' || e.type === 'text' ? e : f.querySelector('input[type=email], input[name=email], input[name=username], input[name=user_name], input[name=user], input[autofocus]'), \
|
||||
F = (i, v) => { if(i) { i.value = v; return true } }, \
|
||||
su = F(u, USERNAME), \
|
||||
sp = F(p, PASSWORD); \
|
||||
if(su && sp) { 'Login filled' } \
|
||||
else if(su) { 'Username filled' } \
|
||||
else if(sp) { 'Password filled' } \
|
||||
else 'Unable to fill login info' \
|
||||
""")
|
||||
command="jseval $(printf '{ let USERNAME="%s", PASSWORD="%s"; %s }' "$username" "$password" "$script" )"
|
||||
;;
|
||||
|
||||
*)
|
||||
command="insert-text ${password}"
|
||||
;;
|
||||
esac
|
||||
|
||||
printf %s\\n "$command" > "$QUTE_FIFO"
|
||||
27
local/share/qutebrowser/userscripts/pipe.sh
Executable file
27
local/share/qutebrowser/userscripts/pipe.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# pipe=/tmp/testpipe
|
||||
|
||||
# trap "rm -f $pipe" EXIT
|
||||
#
|
||||
# if [[ ! -p $pipe ]]; then
|
||||
# mkfifo $pipe
|
||||
# fi
|
||||
|
||||
# echo "$QUTE_FIFO" > $HOME/fifoa
|
||||
#
|
||||
# echo "jseval window.location.href"
|
||||
#
|
||||
# while true
|
||||
# do
|
||||
# if read -r line <"$QUTE_FIFO"; then
|
||||
# if [[ "$line" == 'quit' ]]; then
|
||||
# break
|
||||
# fi
|
||||
# echo "$line"
|
||||
# fi
|
||||
# done
|
||||
#
|
||||
# echo "Reader exiting"
|
||||
|
||||
echo "open -t https://www.dict.cc/?s=$QUTE_SELECTED_TEXT" >> "$QUTE_FIFO"
|
||||
Reference in New Issue
Block a user