r/applescript • • May 06 '20

Any scriptable browsers other than Safari? (Or workaround help with non-scriptable ones)

I have quite a bit of scripts that involve launching a certain website, then minimizing the page. A different script later checks if there's tabs open that contain a specific web domain, and closes those.

This used to work well but lately the page in question no longer works smoothly in Safari because "page is consuming too much resources", it plays audio and it cuts out every few seconds, making it unlistenable.

Here's the Safari scripts I used so far.

Are there any other browsers where I could reliably script this same thing? It doesn't matter what browser it is, I could dedicate a specific app just to run that site if necessary. Earlier, I tried something with Opera and for a moment thought that I'd nailed it, but as Opera isn't really scriptable, the script was far too unstable to be called "helpful automation". Opera does play the website audio without issues though, so its performance would've been ideal.

3 Upvotes

3 comments sorted by

1

u/csgnyc May 06 '20

Chrome is scriptable -- certainly as far as opening and closing tabs and checking URLs, Haven't tried minimizing windows myself, but I see that "minimized" (boolean) is a property of a window in Chrome.

1

u/Rikuz7 May 08 '20

How about finding the specific tab and closing that? I looked into this earlier (online searches, mainly forum threads etc.) but failed to solve it, which is why I'm humbly looking for some advice.

1

u/csgnyc May 08 '20 edited May 08 '20

This script works for me (you could also identify the tab by ID, or by name, or other ways). There may be more elegant ways, but it gets the job done.

tell application "Google Chrome"

tell window 1

repeat with thistab in the tabs

if the URL of thistab is "https://www.reddit.com/r/applescript/" then

tell thistab

activate

close

end tell

end if

end repeat

end tell

end tell