Find text on a page and click next to it

Hello there!

Is it possible to find text on a page and click next to it?

Thanks in advance

What page in what application?

Web page in Firefox browser

Since Firefox is unscriptable, other than finding the image on the screen, you’re probably out of luck.

Maybe you could write some JavaScript and find some way to ask Firefox to execute it.

As @peternlewis says, FF is not scriptable from an external source.
You may want to consider changing to Safari or Chrome for this use case.
Both are very scriptable, and well-supported by KM.

For example, see Google Chrome Actions, Tokens, & Functions (KM Wiki).

Unfortunately, i don’t use chrome or safari because firefox has much better add ons without which i can’t live :slight_smile:

Find image (a screenshot of a text) to find text on a page - is the only solution which i could find.

In that case, you might do a Google search on "firefox inject JavaScript".
Here is one promising hit:
Greasemonkey :: Add-ons for Firefox

I haven't used it, nor even studied the docs, but maybe it will work for you.
If you use it, and figure out a way to use with KM, please post it.

GreaseMonkey, by the way, has been around for at least 10 years. You can see/edit the scripts.

However, one shouldn’t download arbitrary scripts from sources of dubious provenance.

But I think the OP’s use case would have them coding their own scripts.

Another approach is to use a javascript: URL, Cmd+L getting you to the URL bar so you can inject it.

That’s where i came from and started using KM, now i am going back :slight_smile:

Back to Greasemonkey? You might find my javascript: URL approach a little easier.

Could you possibly show an example of this, using a KM macro to set the URL?

1 Like

I know you mentioned these techniques but I'm wondering if you considered using them as follows:

  • Use Cmd-F to search for your text (easy part)
  • Use 'Click at Found Image' with a small image containing only the background color of highlighted text from your Cmd-F.

e.g., this tiny thing:

I’m travelling so won’t immediately code a sample. However

  1. @kraftydevil’s idea of CMD+F has merit.
  2. CMD+L gets to the URL bar and selects the current content. Then typing or pasting should inject JavaScript.

Not to solve the OP's problem but to illustrate how you might drive Firefox from Keyboard Maestro, I uploaded the following test macro:

Okay, for example how can i press a button in a firefox webpage using button’ id?

This should help: https://stackoverflow.com/questions/27200536/how-to-make-a-button-to-be-clicked-when-enter-is-pressed-using-bookmarklet#27221296

1 Like

Just for ease of reference, here's the JavaScript from the above link:

javascript:(function()%7Bdocument.getElementById(%22Form%3Areset%22).click()%7D)()

Late to the party, but I an trying to click the first link whose text is “Undefined” but whose link and all such links is set to javascript:void(0); I can use the find command to find the first instance, I have copied where the hilited text is in the web page and pasted it into the Click at Found Image successfully, but it does not actually click at the found image. Not really sure how to use this feature. This is in Chrome BTW.

There really needs to be an action like Click at link text.

Please post the URL of the page you want to use.

OR

If you can't do this due to privacy reasons, post a screenshot of the HTML provided by the Chrome "Inspect" tool when you right-click on the sub-menu item to be clicked.

To learn how to use the Chrome Inspect tool, see this video:
Demo Chrome Inspect Tool to Identify Tags for JavaScript by JMichaelTX