Часы по задачам за месяц и остаток до нормы, через REST от сессии браузера. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
863 B
JavaScript
17 lines
863 B
JavaScript
chrome.runtime.onInstalled.addListener(({ reason }) => {
|
|
if (reason === 'install') chrome.runtime.openOptionsPage();
|
|
});
|
|
|
|
chrome.action.onClicked.addListener(async tab => {
|
|
const cfg = await chrome.storage.sync.get({ portal: '', norm: 0 });
|
|
if (cfg.portal && !(tab.url || '').startsWith(cfg.portal)) return chrome.tabs.create({ url: cfg.portal });
|
|
const target = { tabId: tab.id };
|
|
try {
|
|
// MAIN — чтобы скрипту были видны BX и сессия портала
|
|
await chrome.scripting.executeScript({ target, world: 'MAIN', func: c => { window.myTimeConfig = c; }, args: [cfg] });
|
|
await chrome.scripting.executeScript({ target, world: 'MAIN', files: ['mytime.js'] });
|
|
} catch {
|
|
chrome.runtime.openOptionsPage(); // служебная страница браузера, туда скрипт не пустят
|
|
}
|
|
});
|