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

如何让Firefox的PDF查看器在文件变更时自动重新加载PDF?

Firefox中PDF文件变更自动刷新方案

基于文件变更触发的自动刷新(推荐)

Firefox原生不支持检测PDF文件变更并自动刷新,但可以通过本地脚本+远程调试实现精准触发:

  • 启动Firefox时开启远程调试端口:右键Firefox快捷方式,修改目标字段为
    firefox.exe --remote-debugging-port=9222
    (Linux/macOS用户直接在终端执行firefox --remote-debugging-port=9222)
  • 编写Python脚本监控PDF文件修改,变更时触发刷新:
    import time
    from watchdog.observers import Observer
    from watchdog.events import FileSystemEventHandler
    import requests
    import json
    
    # 替换成你的PDF文件绝对路径
    TARGET_PDF = "/home/user/docs/notes.pdf"
    DEBUG_PORT = 9222
    
    class PDFWatcher(FileSystemEventHandler):
        def on_modified(self, event):
            if not event.is_directory and event.src_path == TARGET_PDF:
                # 获取所有打开的标签页
                tabs = requests.get(f"http://localhost:{DEBUG_PORT}/json/list").json()
                for tab in tabs:
                    # 匹配打开该PDF的标签页
                    if TARGET_PDF in tab["url"]:
                        # 发送刷新指令
                        requests.post(
                            tab["webSocketDebuggerUrl"],
                            json={"id": 1, "method": "Page.reload"}
                        )
                        print("PDF已自动刷新")
    
    if __name__ == "__main__":
        handler = PDFWatcher()
        observer = Observer()
        observer.schedule(handler, path=TARGET_PDF, recursive=False)
        observer.start()
        try:
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            observer.stop()
        observer.join()
    
  • 安装依赖:pip install watchdog requests,运行脚本后,PDF文件一被修改,对应Firefox标签页就会自动刷新。

定时自动刷新(简易变通方案)

如果不想用脚本,可通过自定义书签实现定时刷新:

  • 新建Firefox书签,名称设为「5秒刷新PDF」,网址栏输入:
    javascript:(function(){setInterval(()=>location.reload(),5000);})();
    
  • 打开PDF后点击该书签,标签页会每5秒自动刷新;停止刷新只需关闭标签页或重新打开PDF。

内容的提问来源于stack exchange,提问作者J. Mini

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.02 07:57:29