diff --git a/scripts/vv b/scripts/vv old mode 100755 new mode 100644 index ba915d0..657a7cb --- a/scripts/vv +++ b/scripts/vv @@ -2,11 +2,11 @@ # vv: VT View -# Version 1.9.3 -# B9 May 2023 +# Version 1.9.4 +# B9 November 2024 # Use sixel graphics to show images inside a terminal (e.g., xterm). -# Copyright (c) 2019..2023 hackerb9, under the terms of GNU GPL 3+. +# Copyright (c) 2019..2024 hackerb9, under the terms of GNU GPL 3+. # Some nice features: # * Can display any image type. (Via ImageMagick). @@ -257,6 +257,16 @@ prerequisites() { echo "Pages: $(identify "$1" | grep -c PDF)" } fi + if command -v chrome >/dev/null; then + dumpdom() { chrome --headless --dump-dom "$@"; } + elif command -v chromium >/dev/null; then + dumpdom() { chromium --headless --dump-dom "$@"; } + else + dumpdom() { + notice "If yandex mistakes w3m for a bot, please install chrome to run headless javascript." + curl "$@" + } + fi if [[ $BASH_VERSINFO -lt 5 ]]; then notice "Kludging read for Bash4" BASH4BUG="-e" @@ -540,7 +550,7 @@ inittermkey() { # To be valid, we must enable terminal application mode key sequences. if tput smkx; then - for k in $(infocmp -L1 | egrep 'key_|cursor_'); do + for k in $(infocmp -L1 | grep -E 'key_|cursor_'); do a=""; x="" # Example "k: key_down=\EOB," a=${k#*key_} @@ -758,7 +768,6 @@ sidebyside() { -auto-orient \ -geometry ">${half}x>$((height-fontheight))" \ -label "$1" "$1" -label "$2" "$2" sixel:- - viewmode=ss SHOULDREDRAW=yup } @@ -821,7 +830,8 @@ reverseimagesearch() { yandeximagesearch() { # Reverse image search using yandex and w3m # Yandex is not the best but has a simple interface we can access - # without javascript. (Unlike Tineye, Bing, and Google.) + # (Unlike Tineye, Bing, and Google). Yandex does require + # javascript, so we use 'chrome --dump-dom' to retrieve the html. local file="$1" local output resultPage deleteme="" # Local vars local scale=">1000x>1000" # Image size to scale to before searching. @@ -838,7 +848,7 @@ yandeximagesearch() { url="https://yandex.com/images/search?rpt=imageview" url+="&format=json" url+='&request=%7B%22blocks%22%3A%5B%7B%22block%22%3A%22cbir-controller__upload%3Aajax%22%7D%5D%7D' - cookie="yp=999999999999.sp.aflt%3A999999999999.szm.1; my=YywBAAA=" + cookie="" # Upload the image and save the output to search through. # Note: Curl's "@filename" splits filenames with commas & semicolons. @@ -872,8 +882,11 @@ yandeximagesearch() { if [[ "$resultPage" ]]; then - echo "Found $(unuriescape "$resultPage")" >&2 - w3m https://yandex.com$resultPage + echo "Found yandex.com/$(unuriescape "$resultPage")" >&2 + dumpdom https://yandex.com$resultPage | + sed 's|
|