Stop macro execution command if string is found on website

In general the check for a substring inside text in Javascript is ${textstring}.includes("abc") == true, and you can use this in IF, WHILE or REPEATIF.

Here is an example. It checks the website until the string “5” shows up at the last digit of the time.

{
  "Name": "checkstring",
  "CreationDate": "2020-3-5",
  "Commands": [

    {
      "Command": "open",
      "Target": "https://www.clocktab.com/",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "medium",
      "Value": "!replayspeed"
    },
    {
      "Command": "do",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "Extract second digit and check for string",
      "Value": "t"
    },
    {
      "Command": "storeText",
      "Target": "id=digit2",
      "Value": "t"
    },
    {
      "Command": "echo",
      "Target": "Extracted digit is t=${t}",
      "Value": "blue"
    },
    {
      "Command": "repeatIf",
      "Target": "${t}.includes(\"5\") == false",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "YES, the 5 digit is shown",
      "Value": "green"
    }
  ]
}
2 Likes