简体   繁体   中英

javascript: how to scroll a small pop-up window

I am currently trying to create a javascript bot, for Instagram, that follows users based on the list of "followers" a user has. I am currently trying to use the Window scrollBy() method to scroll down a small pop-up window that appears when you click following. It would be best if you saw what I am trying to describe as popup window, by nagivating to

instagram.com/instagram

and clicking "followers"

I am not sure if its possible to scroll that small window. Please let me know if it. Currently, the window scrollBy will move the page down, but not the scroll bar in the center, that I'd like it to!

All feedback and code clean-up are appreciated, as I am stilling pretty new with javascript! Thank you!

    for(var i=0;i<3;i++) {
    (function(i) {
    setInterval(clickButton(i), 2000);
    }) (i)
    }
    function clickButton(idx) {
    return function() {
    buttons = document.getElementsByClassName('_aj7mu _2hpcs _95tat _o0442');
    document.getElementsByClassName('_aj7mu _2hpcs _95tat _o0442')[idx].click();
    window.scrollBy(0, 100);
        }
    }

NOTE: I am trying to make this work in Google Chrome Console. Not sure if this will change any responses.

To scroll that element down just declare a variable with its reference:

var popup = document.getElementsByClassName('_4gt3b');

and use the element property scrollTop to define its scroll bar distance from the top:

 popup[0].scrollTop = y;

where y is a variable that you will declare with an integer value in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM