Problem With Chrome Document Title Token?

I add a question mark because the problem no doubt lies not with KM, but between my ears...

However, I've fiddled with making a KM macro to copy the URL and title of the foremost tab in Chrome, and while the Google Chrome Document URL works fine (as does the older %FrontBrowserURL%) -- ie it gets copied to my clipboard as expected -- the Google Chrome Document Title does not -- a blank space is copied to my clipboard, where I'd have expected the title to be.

I've used the following as a guide:

image

Which lives here: How Get Title and URL From the Current Tab in Chrome - #4 by sccardais

I also tried this slightly different approach: Automate Copying and Pasting the Current Page Title and URL with Keyboard Maestro

Any suggestions? Anyone else running into problems with the Chrome Document Title token?

Actually the Front Browser Tokens token are newer than the Google Chrome tokens.

Since you're not showing your work that includes the Chrome token, it's not possible to troubleshoot.

Can you post the simplest possible version of a macro that demonstrates the problem?

Thanks, see attached:

NEW Paste URL and title of current web page in Markdown copy.kmmacros (2.7 KB)

Hey Tom,

I've altered your macro a bit to use a local variable and to display the result.

Ordinarily when testing text-tokens I would just put them directly into a Display Text in a Window action – as that works well, and I can play with the style of the text if I want to.

NEW Paste URL and title of current web page in Markdown copy.kmmacros (3.5 KB)

Macro-Image

Keyboard Maestro Export

So far I've gotten consistent results on every web page I've tested.

Usually when this sort of thing comes up it is a user error – but I'm not seeing anywhere that you went wrong...

My next thought was perhaps you had changed the actual Chrome-based browser attached to the Chrome tokens (you can do that with an expert preference), but you mentioned that the Chrome-URL token was working – and that nixes that possibility.

My next thought is that maybe you were having some issue related to using a global variable. That can sometimes get you into trouble, because its persistent and can seemingly show an anomalous result to a macro when in fact it was never rewritten.

HTH...

-Chris

Many thanks, Chris.

Your approach has taught me a great deal about how best to write and test KM macros.

That said, your solution doesn't work on my box. As happened with my previous macros, the text window in your macro shows the URL correctly, but the browser title (both the Chrome and FrontBrowser tokens) as a blank.

I tested this on 10 different web pages, and got the same results each time. Thoughts on how to proceed? Thank you again for your generous help.

cheers,
Tom

Check your Chrome settings -- specifically "View" menu, "Developer", "Allow JavaScript from Apple Events". You don't need that enabled to get the URL, but you do to get the tab title.

It's a long shot, since I'd expect you to be getting a notification telling you to turn "Allow..." on, but it does exactly replicate your symptoms.

2 Likes

That did it -- many thanks Nige!

I never received any notifications to 'turn on "Allow..."', but enabling JavaScript from Apple Events makes all versions of my (purloined) macro work like a charm.

1 Like