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 comment
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 comment
  • 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 comment
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 comment
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 comment

@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 comment
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 comment
  • vitor changed the title to Get frontmost tab’s url and title of various browsers
  • vitor changed the title to [How To] Get frontmost tab’s url and title of various browsers
  • vitor unpinned this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...