SPB Git

Repository Public Research preview

click.applescript 770 B 12 lines

1-- Click the first element matching a CSS selector. Prints "ok" or "not-found".2-- Usage: osascript click.applescript <window-id> <tab-index> '<css-selector>'3-- el.click() runs the page's handlers and follows links. It does not move the real pointer.4on run argv5	set w to (item 1 of argv) as integer6	set t to (item 2 of argv) as integer7	set sel to do shell script "/usr/bin/python3 -c 'import sys,urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=\"\"))' " & quoted form of (item 3 of argv)8	tell application "Safari"9		return do JavaScript "(function(s){var el=document.querySelector(s); if(!el) return 'not-found'; el.scrollIntoView({block:'center'}); el.click(); return 'ok';})(decodeURIComponent('" & sel & "'))" in tab t of window id w10	end tell11end run12
Files main
Menu

Theme