简体   繁体   English

javascript:如何滚动一个小的弹出窗口

[英]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. 我目前正在尝试为Instagram创建一个JavaScript机器人,根据用户拥有的“关注者”列表来关注用户。 I am currently trying to use the Window scrollBy() method to scroll down a small pop-up window that appears when you click following. 我当前正在尝试使用Window scrollBy()方法向下滚动一个小的弹出窗口,当您单击下面的窗口时出现。 It would be best if you saw what I am trying to describe as popup window, by nagivating to 最好是通过导航到我看到我要描述为弹出窗口的内容

instagram.com/instagram 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! 目前,窗口scrollBy会将页面向下移动,但不希望中间的滚动条向下移动!

All feedback and code clean-up are appreciated, as I am stilling pretty new with javascript! 感谢所有反馈和代码清理,因为我仍在使用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. 注意:我正在尝试在Google Chrome控制台中执行此操作。 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: 并使用元素属性scrollTop定义其滚动条到顶部的距离:

 popup[0].scrollTop = y;

where y is a variable that you will declare with an integer value in it. 其中y是一个变量,您将在其中声明一个整数值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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