2

FireFox で特定のタイトルのタブを閉じるスクリプトを作成する必要があります。以下の AppleScript の例に相当する FireFox はありますか?

Safari でタブを閉じます。

tell application "Safari"
    delete (every tab of every window where its name contains "[done]")
end tell

Chrome でタブを閉じる:

tell application "Google Chrome"
    delete (every tab of every window where its title contains "[done]")
end tell
4

1 に答える 1

5

Firefox は AppleScript をサポートしていないため、UI スクリプトに依存する必要があります。もちろん、Firefox の非標準 UI も役に立ちませんが、それでも可能です。これを試して:

tell application "System Events" to tell process "firefox"
    set frontmost to true
    repeat with w from 1 to count of windows
        perform action "AXRaise" of window w
        set startTab to name of window 1
        repeat
            if name of window 1 contains "[done]" then
                keystroke "w" using command down
            else
                keystroke "}" using command down
            end if
            delay 0.2
            if name of window 1 is startTab then exit repeat
        end repeat
    end repeat
end tell
于 2012-09-15T06:17:04.130 に答える