Расширение «Моё время в Битрикс24»
Часы по задачам за месяц и остаток до нормы, через REST от сессии браузера. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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(); // служебная страница браузера, туда скрипт не пустят
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user