bash - Run command line script on load of a web page -
i want bash script sits , listens , runs script when load specific web page in browser. wondering if possible, , if so, how go it?
i'm thinking should possible somehow. i'm on mac , in /etc/hosts file can specify specific websites should blocked, e.g. "www.facebook.com".
so in short. (and how) possible run bash script when computers browser navigates webpage, example "www.facebook.com"?
updated answer
if want matching of name of site pre-defined site, , something, script this:
#!/bin/bash while :; site=$(osascript -e 'tell application "safari" return url of front document') if [[ $site =~ stackoverflow ]]; "stack overflow! quality site" fi sleep 1 done original answer
you aren't specific browser using, page or want do, script sits , watches safari , asks page looking @ , prints in terminal. modify detect pages , run script when navigate them.
#!/bin/bash while :; osascript -e 'tell application "safari" return url of front document' sleep 1 done put above in file called monitorsafari in home directory. go terminal , type following once make executable:
chmod +x monitorsafari then can run either double-clicking in finder, or typing
./monitorsafari in terminal. prints page on once every second.
Comments
Post a Comment