如果带有 iMacros 的页面中存在文本,请单击按钮



我正在尝试将 iMacros 与 Firefox 一起使用,以单击取消关注按钮,前提是页面上存在此代码......

<small class="follow-status">follows you</small>

如果页面源代码中不存在上述内容,那么它将运行此 iMacros 代码...

TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow

根据我所读到的内容,没有if/else类型语法,但您可以使用以下命令运行Javascript

EVAL("Javascript code here")

如果有人知道我该怎么做,我真的可以使用帮助

你可以欺骗 Imacros 做一个 If 语句,但首先你必须为这个宏SET !ERRORIGNORE YES。然后:

SET EXTRACT NULL
'if this exist you extract the text(even if you know it)
'if doesn't exist should return error but we turned that off; Extract remains Null
TAG POS=1 TYPE=SMALL ATTR=TXT:follows<SP>you EXTRACT=TXT
SET !VAR1 EVAL("var text="{{!EXTRACT}}"; if(text=="follows you") text = "jibber";else text = "UnFollow";text;")
'this one executes if the text is right, if not should give error but we turned that off
TAG POS=1 TYPE=DIV ATTR=TXT:{{!VAR1}}

为此使用 javascript 文件

run();
function run() {
  var exists = doesElementExist();
  alert('element exists? ' + exists);
  if (exists) {
    iimPlay('CODE: TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow');
  }
  else {
    // do something else here
  }
}
// test if element exists
function doesElementExist() {
  iimDisplay('looking for small element with class "follow-status" on page');
  var code = iimPlay('CODE: SET !TIMEOUT_TAG 1n'
                     + 'TAG POS=1 TYPE=SMALL ATTR=CLASS:follow-status EXTRACT=TXT');
  if (code !==1) {
    return false;
  }
  var extract = iimGetLastExtract();
  if (extract === '#EANF#') {
    return false;
  }
  return true;
}

最新更新