3

我正在尝试将 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")

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

4

2 回答 2

7

你可以欺骗 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}}
于 2012-11-29T01:37:50.693 回答
2

为此使用 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 1\n'
                     + '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;
}
于 2013-01-30T12:42:59.247 回答