Files
Alex CubeandClaude Opus 5.5 c701f07483 Расширение «Моё время в Битрикс24»
Часы по задачам за месяц и остаток до нормы, через REST от сессии браузера.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 01:14:06 +03:00

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(); // служебная страница браузера, туда скрипт не пустят
}
});