0

我有这个 Twitter 扫描仪(一个 Google Chrome 扩展),我想只执行一次这个 IF 语句。之后我仍然希望它能够扫描 other shoeName,但是我设置的标志不断被重置。

这是我的代码:

function twitterScan() {

    for (var i = 0; i < 4; i++) {
        tweetName[i] = document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;
        tweet[i] = document.getElementsByClassName("js-tweet-text")[i].innerHTML;
    }
    var flag = true;
    var flag1 = true;

    //if (document.getElementsByClassName("fullname js-action-profile-name show-popup-with-id")[0].innerHTML;

    if (tweet[0].match(shoeName) == shoeName && flag == true||(tweet[0].match(shoeName1) == shoeName1 && flag1 == true) {
        if(tweet[0].match(shoeName) == shoeName) 
            flag = false;
        if(tweet[0].match(shoeName1) == shoeName1)
            flag1 = false;
        document.getElementsByClassName("twitter-timeline-link")[0].click();
        tFunction = "get outa here";
        shoeName = " 4444  4 456 7 8 456 7 345 7 345  345 3 1 1 133s "; //buffer to jump out of interval loop
    } 
}
4

1 回答 1

0

从哪里调用 twitterScan()?

您是否尝试过将 flag 和 flag1 移到函数之外?

var flag = true;
var flag1 = true;
function twitterScan() { ... }
于 2013-07-18T04:22:40.800 回答