You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
930 B
46 lines
930 B
/**
|
|
* Runs when the extensions is updated
|
|
* @param {string} tabId
|
|
* @param {*} changeInfo
|
|
* @param {*} tab
|
|
*/
|
|
const updated = (tabId, changeInfo, tab) => {
|
|
if (changeInfo.status == 'complete' && tab.active) {
|
|
chrome.tabs.executeScript(tab.ib, {
|
|
file: 'login.js',
|
|
});
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Run when extensions is installed
|
|
*/
|
|
const installed = () => {
|
|
window.open('@pages/options.html', '_blank');
|
|
|
|
getAccounts((accounts) => {
|
|
chrome.storage.sync.set(
|
|
{
|
|
enabled: true,
|
|
accounts: accounts || [],
|
|
},
|
|
() => getAccounts(console.log)
|
|
);
|
|
});
|
|
|
|
chrome.browserAction.setBadgeText({
|
|
text: 'ON',
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get the all the accounts that are currently added
|
|
* @param {() => void} callback
|
|
*/
|
|
const getAccounts = (callback) => {
|
|
chrome.storage.sync.get('accounts', ({ accounts }) => callback(accounts));
|
|
};
|
|
|
|
chrome.tabs.onUpdated.addListener(updated);
|
|
chrome.runtime.onInstalled.addListener(installed);
|