Jump to content

[HOW TO] Get frontmost tab’s url and title of various browsers


Recommended Posts

4 hours ago, deanishe said:

It needs to set the variable because it turns accessibility off before returning it, doesn’t it?

 

Yes, my mistake. I somehow missed the intermediary line and saw set and return as coming right after each other.


On the larger point, I’m glad someone is still trying but I think it’s more likely for AppleScript to die than for Firefox to ever support it properly. Maybe we’ll get something when Shortcuts comes to macOS (if that’s going to be scriptable at all, which is a big “if”), but even then probably not before Firefox switches to Servo, assuming that’s ever going to happen.

Link to post
  • Replies 58
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I’ve been seeing a lot of workflows that need to interact with a browser via AppleScript (usually to get a page’s url), but most of them seem to settle on a single browser (usually Safari), which is a

This thread isn't about a workflow…

@derBingle That method seems fine, but I won’t add it to the list because it’s a bit hackish. For it to be added to the gist, it needs to be part of the app’s AppleScript dictionary and have both URL

Posted Images

On 8/10/2020 at 12:06 PM, vitor said:

Firefox switches to Servo, assuming that’s ever going to happen.

 

Seems like that team got gutted in the recent layoffs, so forget that. They should’ve fired the executives instead, beginning with the ones that lead the Pocket acquisition and the Mr. Robot crossover. I have no hope for the future (or present) of Mozilla or Firefox.

 

I do hope that Rust can survive independently.

Link to post
  • 2 weeks later...
  • 1 month later...

@vitor Copied and pasted your gist in a Run script action, tried to run the script in Brave Browser (v85.1.14.84) and got this error message: 

 

Quote

[19:47:36.051] 000000 Browser url[Keyword] Processing complete

[19:47:36.058] 000000 Browser url[Keyword] Passing output '' to Run Script

[19:47:36.938] ERROR: 000000 Browser url[Run Script] /Users/Usersname/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/09DB6E53-6D96-4F96-AC21-E898327770B1:19:128: script error: Error on line 3: SyntaxError: Unexpected identifier 'is'. Parse error. (-2700)

 

Link to post
2 minutes ago, politicus said:

Copied and pasted your gist

 

You’re not supposed to copy everything. Read the comments and copy only the parts you need.

 

2 minutes ago, politicus said:

in a Run script action

 

Are you sure you set it to the correct language?

 

Link to post
Posted (edited)
9 minutes ago, politicus said:

Here is how I have configured the Run script action that is triggered by a keyword action:

 

And you’re saying that that’s causing the error above? Doesn’t really seem possible. Check the error message you posted:

 

39 minutes ago, politicus said:

Error on line 3: SyntaxError: Unexpected identifier 'is'. Parse error. (-2700)

 

Not only is there no is on that script, it’s only two lines long! Wherever your problem is, it’s not in there.


Also, the way you’ve set it up you’ll only get the URL because it’s the last line. To get them both, you’ll need to have them in the same line connected by a + or + '\n' +, to get them on different lines.

Edited by vitor
Link to post

@vitor Feeling really stupid... My last from is the script I try to make work AFTER I red your message. 

 

Of course there is no error message. Plus, it is working like a charm now that I added a Copy to clipboard action.

 

Thank you!

 

Where does the output of this script go (the two lines script I posted before) by default? I expected it to be automatically copied to the system clipboard and therefore didn't understand why my Alfred clipboard newest entry didn't change.

Link to post
17 hours ago, politicus said:

Where does the output of this script go (the two lines script I posted before) by default?

 

osascript implicitly writes the return value of the last evaluation to STDOUT, so the script will print the tab URL. The tab title is lost because you don’t do anything with the return value.

 

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...