Skip to content

Commit

Permalink
Abstracted sendMsgToActiveTab()
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Nov 18, 2024
1 parent a4297e4 commit 74a5de7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions extension/popup/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@

// Define FUNCTIONS

function notify(msg) {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, {
action: 'notify', msg: msg, pos: 'bottom-right' })
})}
async function sendMsgToActiveTab(req) {
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true })
return await chrome.tabs.sendMessage(activeTab.id, req)
}

function syncStorageToUI() {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { action: 'syncStorageToUI' })
})}
function notify(msg) { sendMsgToActiveTab({ action: 'notify', msg: msg, pos: 'bottom-right' })}
function syncStorageToUI() { return sendMsgToActiveTab({ action: 'sync.storageToUI' })}

function updateGreyness() {

Expand Down

0 comments on commit 74a5de7

Please sign in to comment.