sesweitzer
-
Posts
6 -
Joined
-
Last visited
Reputation Activity
-
sesweitzer reacted to deanishe in Need a workflow to close left tabs or right tabs in Safari
And here's "Close Tabs to Right":
// Close Safari tabs to the right of the active one. ObjC.import('stdlib') function run(argv) { var count = 0, safari = Application('Safari'), win = safari.windows[0], tabs = win.tabs, currentIdx = win.currentTab.index(); // console.log('Tab ' + currentIdx + '/' + tabs.length + ' active.'); if (currentIdx == tabs.length) { console.log('No tabs to close.') return } var first = tabs.length - 1, last = currentIdx; for (i = first; i >= last; i--) { // console.log('Closing tab ' + (i+1) + ' ...'); var tab = tabs[i]; tabs[i].close(); count++; } console.log(count + ' tab(s) closed'); }
-
sesweitzer reacted to deanishe in Need a workflow to close left tabs or right tabs in Safari
Put this in a Run Script Action with Language = /usr/bin/osascript (JS)
// Close Safari tabs to the left of the active one. ObjC.import('stdlib') function run(argv) { var count = 0, safari = Application('Safari'), win = safari.windows[0], tabs = win.tabs, currentIdx = win.currentTab.index(); if (currentIdx == 1) { console.log('No tabs to close.') return } // start at currentIdx - 2 due to 0-indexing in JS for (i = currentIdx - 2; i >= 0; i--) { var tab = tabs[i]; tabs[i].close(); count++; } console.log(count + ' tab(s) closed'); }