0

I have this Twitter scanner (a Google Chrome extension), that I want to execute this IF statement exactly once. After that I still want it to be able to scan for other shoeName, but my flag that I set keeps getting reset.

Here is my code:

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
    } 
}
Xan
  • 74,770
  • 16
  • 179
  • 206

1 Answers1

0

From where is twitterScan() called?

Have you tried moving flag & flag1 outside the function?

var flag = true;
var flag1 = true;
function twitterScan() { ... }
shauvik
  • 3,912
  • 2
  • 23
  • 18
  • it is getting called right outside the function twitterscan setTimeout(tFunction, 10); declaring the variables outside the fucntion doesnt work.. I am trying to keep the twitter so its listening the entire time for the next link that I am intrested in – shereaf helmy Jul 18 '13 at 14:05
  • Exactly! That is why you need to pull these variables outside the function as running the function every 10 milliseconds updates their values. – shauvik Jul 22 '13 at 00:03