From df68375d7bcb1b808cfed453658e33456ac57de9 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sat, 27 Apr 2024 23:33:46 +0800 Subject: [PATCH] make query a synchronous function --- scripts/GUI/tabs.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/GUI/tabs.js b/scripts/GUI/tabs.js index 5933299..1c59ca6 100644 --- a/scripts/GUI/tabs.js +++ b/scripts/GUI/tabs.js @@ -29,15 +29,12 @@ export default class Tabs { @param {Object} filters The filters on tab search @param {number} index the tab number to return */ - static async query(filters, index) { + static query(filters, index) { filters = ((typeof filters).includes(`obj`) && filters != null) ? filters : { active: true, currentWindow: true}; - let TABS = {}; - - TABS.all = await chrome.tabs.query(filters); - TABS.result = (index != null) - ? TABS.all[Math.abs(parseFloat(index))] - : TABS.all; - - return (TABS.result); + return ((chrome.tabs.query(filters)).then((TABS_ALL) => { + return ((index != null) + ? TABS_ALL[Math.abs(parseFloat(index))] + : TABS_ALL); + })); } } \ No newline at end of file