Skip to content

Commit

Permalink
chore: replace callbacks with promises where API available
Browse files Browse the repository at this point in the history
  • Loading branch information
kineticjs committed Jan 17, 2024
1 parent 44d8e91 commit 0ac1012
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/scripts/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/modules/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 0ac1012

Please sign in to comment.