From 9ac11c1f42cfb9d76331b0416b360b144a73e220 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Thu, 28 Jun 2018 20:02:56 -0400 Subject: [PATCH] Change getTabs to getWindows --- src/ts/tabs.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ts/tabs.ts b/src/ts/tabs.ts index d1d9e86..458ded8 100644 --- a/src/ts/tabs.ts +++ b/src/ts/tabs.ts @@ -1,5 +1,16 @@ -export {getTabs}; +export {getWindows}; -function getTabs(callback) { - chrome.tabs.query({}, callback); +let windowCache: chrome.windows.Window[] = []; + +/** + * getWindows gets all windows and their tabs, and stores them for future use. + * + * @param {(windows: chrome.windows.Window[]) => void} callback + * @returns {void} + */ +function getWindows(callback: (windows: chrome.windows.Window[]) => void): void { + chrome.windows.getAll({populate: true}, (windows : chrome.windows.Window[]) => { + windowCache = windows; + callback(windows); + }); }