Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 在Safari中关闭当前站点的所有选项卡是否是一种退出方式?_Macos_Browser_Terminal_Safari_Applescript - Fatal编程技术网

Macos 在Safari中关闭当前站点的所有选项卡是否是一种退出方式?

Macos 在Safari中关闭当前站点的所有选项卡是否是一种退出方式?,macos,browser,terminal,safari,applescript,Macos,Browser,Terminal,Safari,Applescript,作为一个活跃的浏览器用户,我希望在完成项目或完成当前站点后,能够关闭仅与特定站点相关的所有选项卡 我知道有一些快捷方式可以快速关闭所有选项卡 -当前选项卡以外的选项卡 -网络浏览器 -当前窗口 -等 但是,没有办法只关闭所需的站点 是否可以使用快速关闭当前站点 浏览器或 带有AppleScript或BetterTouchTool的终端此脚本关闭Safari每个窗口中与当前选项卡具有相同域的每个选项卡: tell application "Safari" tell window 1

作为一个活跃的浏览器用户,我希望在完成项目或完成当前站点后,能够关闭仅与特定站点相关的所有选项卡

我知道有一些快捷方式可以快速关闭所有选项卡 -当前选项卡以外的选项卡 -网络浏览器 -当前窗口 -等

但是,没有办法只关闭所需的站点

是否可以使用快速关闭当前站点 浏览器或
带有AppleScript或BetterTouchTool的终端此脚本关闭Safari每个窗口中与当前选项卡具有相同域的每个选项卡:

tell application "Safari"
    tell window 1
        set theURL to URL of current tab
    end tell
    set theDomain to my domainOfURL(theURL)
    set windowList to every window
    repeat with aWindow in windowList
        tell aWindow
            close (every tab whose URL begins with theDomain)
        end tell
    end repeat
end tell

on domainOfURL(aURL)
    set tid to my text item delimiters
    set my text item delimiters to "/"
    set theDomain to text items 1 through 3 of aURL as text
    set my text item delimiters to tid
    return theDomain
end domainOfURL

此脚本关闭Safari每个窗口中与当前选项卡具有相同域的每个选项卡:

tell application "Safari"
    tell window 1
        set theURL to URL of current tab
    end tell
    set theDomain to my domainOfURL(theURL)
    set windowList to every window
    repeat with aWindow in windowList
        tell aWindow
            close (every tab whose URL begins with theDomain)
        end tell
    end repeat
end tell

on domainOfURL(aURL)
    set tid to my text item delimiters
    set my text item delimiters to "/"
    set theDomain to text items 1 through 3 of aURL as text
    set my text item delimiters to tid
    return theDomain
end domainOfURL