You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome浏览器中Facebook好友请求页面自动滚动问题求助

解决Facebook好友请求页面自动滚动失效的问题

针对Facebook好友请求页面的自动滚动需求,之前的通用脚本/扩展失效主要是因为页面采用动态生成的元素类名,且滚动容器并非全局window,而是特定的内部div容器。以下是针对性的解决方案:

临时解决方案(控制台运行脚本)

  1. 打开Facebook好友请求页面,按F12打开开发者工具,切换到Console标签
  2. 粘贴并运行以下脚本:
// 定位好友请求列表的滚动容器
const scrollContainer = document.querySelector('div[role="main"] div[aria-label="好友请求"]') || document.querySelector('div.x1yztbdb.x1n2onr6.xh8yej3');

if (scrollContainer) {
  const scrollInterval = 2000; // 滚动间隔(毫秒)
  let isScrolling = true;

  const autoScroll = () => {
    // 滚动到容器底部
    scrollContainer.scrollTop = scrollContainer.scrollHeight;
    
    // 监听容器内容变化,加载新内容后继续滚动
    const observer = new MutationObserver(() => {
      setTimeout(() => isScrolling && autoScroll(), scrollInterval);
      observer.disconnect();
    });

    observer.observe(scrollContainer, { childList: true, subtree: true });
  };

  autoScroll();
  console.log('自动滚动已启动,输入 `isScrolling = false;` 可停止');
} else {
  console.error('未找到滚动容器,请检查页面元素结构');
}

永久解决方案(油猴脚本)

如果需要每次打开页面自动执行,可使用Tampermonkey油猴脚本:

// ==UserScript==
// @name         Facebook好友请求自动滚动
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动滚动加载Facebook好友请求列表
// @match        https://www.facebook.com/friends/requests*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 延迟等待页面元素加载完成
    setTimeout(() => {
        const scrollContainer = document.querySelector('div[role="main"] div[aria-label="好友请求"]') || document.querySelector('div.x1yztbdb.x1n2onr6.xh8yej3');

        if (scrollContainer) {
            const scrollInterval = 2000;
            let isScrolling = true;

            const autoScroll = () => {
                scrollContainer.scrollTop = scrollContainer.scrollHeight;
                const observer = new MutationObserver(() => {
                    setTimeout(() => isScrolling && autoScroll(), scrollInterval);
                    observer.disconnect();
                });
                observer.observe(scrollContainer, { childList: true, subtree: true });
            };

            autoScroll();
        }
    }, 3000);
})();

注意事项

  • Facebook会不定期更新页面结构,如果脚本失效,需要重新通过开发者工具的元素选择器,定位当前的滚动容器(通常是带有滚动条的div),替换脚本中的选择器即可。
  • 不要设置过短的滚动间隔,避免触发Facebook的反爬限制。

内容的提问来源于stack exchange,提问作者aanchal gupta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.02 05:53:09