From 0ac101287623f2d169d39047f9848585a3a4f9a4 Mon Sep 17 00:00:00 2001 From: Diana Pazheva Date: Thu, 18 Jan 2024 00:26:48 +0200 Subject: [PATCH] chore: replace callbacks with promises where API available --- app/scripts/background/main.js | 4 ++-- app/scripts/modules/utils/utils.js | 4 ++-- app/scripts/popup/popup.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/scripts/background/main.js b/app/scripts/background/main.js index b260502c..760f665e 100644 --- a/app/scripts/background/main.js +++ b/app/scripts/background/main.js @@ -60,8 +60,8 @@ * @param {Object} message */ 'do-script-injection': function (message) { - chrome.windows.getCurrent(w => { - chrome.tabs.query({ active: true, windowId: w.id }, tabs => { + chrome.windows.getCurrent().then(w => { + chrome.tabs.query({ active: true, windowId: w.id }).then(tabs => { chrome.scripting.executeScript({ target: { // inject the script only into the frame diff --git a/app/scripts/modules/utils/utils.js b/app/scripts/modules/utils/utils.js index e6f95d37..c0d8f97a 100644 --- a/app/scripts/modules/utils/utils.js +++ b/app/scripts/modules/utils/utils.js @@ -128,8 +128,8 @@ function _getPort () { function _sendToAll(message, callback) { var frameId = message.frameId; var options; - chrome.windows.getCurrent(w => { - chrome.tabs.query({ active: true, windowId: w.id }, tabs => { + chrome.windows.getCurrent().then(w => { + chrome.tabs.query({ active: true, windowId: w.id }).then(tabs => { // options.frameId allows to send the message to // a specific frame instead of all frames in the tab if (frameId !== undefined) { diff --git a/app/scripts/popup/popup.ts b/app/scripts/popup/popup.ts index 13a019aa..3cb794ff 100644 --- a/app/scripts/popup/popup.ts +++ b/app/scripts/popup/popup.ts @@ -2,7 +2,7 @@ var utils = require('../modules/utils/utils.js'); -window.chrome.tabs.query({active: true, currentWindow: true}, function (tabs) { +window.chrome.tabs.query({active: true, currentWindow: true}).then(function (tabs) { // Create a port with background page for continuous message communication var port = utils.getPort();