How do i trigger a snippet if a specific "Text" is found on the webpage?

how do i trigger a snippet if a specific "Text" is found on the webpage?

Hello, welcome to the community!

Triggering a snippet automatically is not possible, but you can use the {site} command to check if certain text is on the page, and then trigger different logic in your snippet based on that. You may want to mix it with the {if} command.

Hey @Rain

Can you please also share more details about your proposed workflow? A video showing the steps you want to automate would help us understand this further. Thanks!

Hi Gaurav! Please see below for the short vid. Basically, I'd like the snippet to send an inmail if the page shows "free to inmail" and skip it if it doesn't. Is this possible? Sorry, I'm new to this,

Thanks for the clarification video. So, you wish to type the shortcut first (/inmail), then the snippet will run if the page shows "free to inmail"; otherwise, the snippet will do nothing. Is that right?

1 Like

Yes, that is correct.

You may already be able to do it, like so:

{is_free_to_inmail=catch({site: text; selector=selector}, "NO")}
{if: is_free_to_inmail<>"NO"}your snippet goes here...{endif}

You need to update the {site} selector to select the free to in-mail button.

When the button does not exist, the catch() function will handle it, setting the value of is_free_to_inmail to "NO". The if condition below will then not execute your snippet.

When the button does exist, the value of is_free_to_inmail will not be "NO", so the part inside the if condition will execute.

Let us know if it works for you.

I'm using the same LinkedIn tooling. Not sure if this could work with a selector. LinkedIn is very keen on disabling all possibilities to automate. This is the html of that part of the site:

<div class="compose-credits animate-fadein" data-live-test-inmail-credit="">
    <span data-live-test-inmail-credit-text="">
        1/442 InMail-tegoedpunten
          </span>

<!----></div>

How should we target the right selector in this case?

Hey @boudewijn Can you share the HTML part of the site when the text "Free to inmail" is shown instead?

The snippet may be different for non-English languages. If possible, please send me the full screenshot here on the forum, or via a DM, or via an email at gaurang@blaze.today


The part in the yellow box contains the text ("Gratis InMail" == "Free to InMail") and a hoverable information button explaining why the InMail is free.

I see. Can you try this snippet?

{is_free_to_inmail=catch(testregex({site: text; selector=.compose-credits}, "Gratis InMail"), "no")}
{if: is_free_to_inmail<>"no"}your snippet goes here...{endif}

This checks for the text "Gratis InMail". If you're using the English version of LinkedIn, you can update the text accordingly.