1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Timeout in pinterest following script not working

Discussion in 'HTML & JavaScript' started by Toern, Feb 15, 2017.

Tags:
  1. Toern

    Toern Newbie

    Joined:
    Feb 15, 2017
    Messages:
    38
    Likes Received:
    8
    Gender:
    Male
    Location:
    Sweden
    I'm making a simple script for mass-following boards. The only thing left is a working timeout, in order to avoid algorithm detection.

    Here is what i have. It follows all the boards on a page, but does so instantaneously

    Code:
    var buttonsx = document.getElementsByClassName('BoardFollowButton');
    function removeClass(el, className) {    //remove class without jquery
      if (el.classList)
        el.classList.remove(className)
      else if (hasClass(el, className)) {
        var reg = new RegExp('(\\s|^)' + className + '(\\s|$)')
        el.className=el.className.replace(reg, ' ')
      }
    }
    function clicket(el) {    //could not do this inline for some reason
        el.click();
    }
    for (i = 0; i< buttonsx.length; i++) {
      if (!buttonsx[i].classList.contains("followed")) {
        removeClass(buttonsx[i], 'notNavigatable')     // not sure if this matters
        var timeOut = timeOut + Math.random() * 2000 + 500;    // 0.5 - 2.5 seconds extra for each button
        setTimeout(clicket(buttonsx[i]), timeOut);
      } 
    }
    
    I'm a bit of an amateur and it was a while since I did any coding, so could use some help here.