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

如何用AppleScript批量打开指定格式的作业View链接到新标签页?

批量打开作业批改页面的AppleScript修改方案

以下是针对需求修改后的AppleScript,实现批量打开指定编号的作业批改页面,同时避免重复打开已存在的标签页:

tell application "Google Chrome"
    -- 替换为需要批改的作业编号列表,用逗号分隔
    set assignmentNumbers to {1001, 1002, 1003, 1004, 1005}
    -- 作业页面的基础URL(末尾保留斜杠)
    set baseURL to "https://SCHOOLURL.org/submissions/view/"
    
    -- 循环处理每个作业编号
    repeat with num in assignmentNumbers
        set targetURL to baseURL & num
        set pageIsOpen to false
        
        -- 检查所有Chrome窗口的标签页,判断页面是否已打开
        repeat with win in windows
            repeat with tabItem in tabs of win
                if URL of tabItem is targetURL then
                    set pageIsOpen to true
                    -- 可选:如果页面已打开,自动切换到该标签页
                    set active tab index of win to (index of tabItem)
                    set index of win to 1
                    exit repeat
                end if
            end repeat
            if pageIsOpen then exit repeat
        end repeat
        
        -- 若页面未打开,在当前窗口新建标签页打开
        if not pageIsOpen then
            tell window 1
                make new tab with properties {URL:targetURL}
            end tell
        end if
    end repeat
end tell

使用说明

  • 配置作业编号:将assignmentNumbers数组中的示例编号替换为你实际需要批改的作业编号,可直接批量粘贴整理好的编号(格式为{编号1, 编号2, ...})。
  • 基础URL验证:确保baseURL与作业页面的实际URL结构匹配(比如如果单个作业URL是https://SCHOOLURL.org/submissions/view/1001,则基础URL末尾的斜杠不能省略)。
  • 重复页面处理:脚本会自动跳过已打开的作业页面,若启用了“自动切换到已打开标签页”的逻辑,还会直接定位到已存在的页面。

可选优化

如果需要在新窗口中打开所有作业页面,可将新建标签页的代码替换为:

make new window with properties {URL:targetURL}

内容的提问来源于stack exchange,提问作者Shannon McNamara

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 16:52:22