Skip to content

Commit

Permalink
Activate the corresponding window when it's possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekyeom committed Feb 12, 2022
1 parent ddd6a4e commit ecd4edc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/focus-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ function run(args) {

chrome.windows[windowIndex].visible = true;
chrome.windows[windowIndex].activeTabIndex = tabIndex + 1;
let windowTitle = chrome.windows[windowIndex].title();
chrome.windows[windowIndex].index = 1;
chrome.activate();

let candidateWindows = Array.prototype.filter.call(
Application("System Events").processes[browser].windows,
function(w) {
return w.name().startsWith(windowTitle + ' - ');
},
);
if (candidateWindows.length == 1) {
candidateWindows[0].actions['AXRaise'].perform();
}
}

0 comments on commit ecd4edc

Please sign in to comment.