Chatwork業務アシスタント 3.3.1
“Chatworkの自分宛メッセージと自分の送信メッセージを分析し、返信・リアクション状況から「まだ対応していないもの」を自動で抽出して一覧表示します。対応漏れの防止に役立ちます。Google Sheetsと連携した進捗チェックやレス検索にも対応。”
Archive contains Mozilla COSE digest manifestArchive contains Mozilla COSE signature file
SHA-256068b6d88e955a82a5ba3f007d46a0e1d844a4f05eab3e368485f9a77e605b278
Evidence
1:18… ==============================================
2// Chatwork業務アシスタント - background.js
3// ============================================================
4
5// ── 定数 ─────────────────────────────────────────────────────
6const CW_BASE = 'https://api.chatwork.com/v2';
7const SHEETS_BASE = 'https://sheets.googleapis.com/v4/spreadsheets';
8const RATE_LIMIT_MAX = 280;
9const MSG_CACHE_DAYS = 40;
10const MSG_PER_ROOM = 3000;
11const ROOMS_CACHE_TTL = 10 * 60000;
12const SHEET_CACHE_TTL = 30 * 60000;
13
14// ── タブ定義 ──────────────────────────────────────────────────
15const TAB_DEFINITIONS = [
16 { id: 'alerts', label: '🔔 アラート', requiresOAuth: false, defaultVisible: true, fixed: true, description: '受信未対応・送信未返信の確認' },
17 { id: 'sheet-check', label: '📋 チェック', requiresOAuth: true, defaultVisible: false, fixed: false, description: 'シートと連携した返信チェック(動画コーススキル支援員用・要Google連携)' },
18 { id: 'messages', label: '🔍 レス検索', requiresOAuth: false, defaultVisible: true, fixed: false, description: '自分宛レス・返信の検索' },
19 { id: 'memo', label: '📝 メモ', requiresOAuth: false, defaultVisible: true, fixed: false, description: 'フォルダ・チェックリスト付きのメモ帳' },
20 { id: 'report', label: 'レポート', requiresOAuth: false, defaultVisible: true, fixed: false, description: '月次の集計を確認して集計用ルームへ送信します' },
21 { id: 'debug', label: '🐞 デバッグ', requiresOAut …
21:78… aultVisible: false, fixed: false, description: '不具合調査用の情報を1ファイルに収集(設定のタブ表示でONにできます)' },
22];
23
24// ── レートリミット管理 ────────────────────────────────────────
25let reqCount = 0;
26let reqWindowStart = Date.now();
27
28function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
29
30async function rateCheck() {
⋯10 lines
⋯7 lines
48 // Service Worker起動直後はstorage読み込みが一瞬空を返すことがあるためリトライ
49 for (let i = 0; i < 3; i++) {
50 const { chatworkToken } = await browser.storage.local.get('chatworkToken');
51 if (chatworkToken) return chatworkToken;
52 if (i < 2) await sleep(200);
53 }
54 return null;
⋯5 lines
59:75… ���ていません');
60 await rateCheck();
61 const res = await fetch(`${CW_BASE}${endpoint}`, {
62 headers: { 'X-ChatWorkToken': chatworkToken }
63 });
64 if (res.status === 429) { await sleep(35000); return cwGet(endpoint); }
65 // 204 No Content = 新着メッセージなし → 空配列を返す(正常系)
66 if (res.status === 204) return [];
67 if (!res.ok) {
68 const txt = await res.text();
69 throw new Error(`CW API Error ${res.status}: ${txt}`);
70 }
71 // レスポンスボディが空の場合(一部APIが� …
77:105… ───────────────────
78const OAUTH_SCOPE = 'https://www.googleapis.com/auth/spreadsheets';
79
80// リダイレクトURLを取得(設定画面に表示し、認証リクエストにも使う)
81// 【Firefox】identity.getRedirectURL() は https://<hash>.extensions.allizom.org/ を返すが、
82// このドメインはMozillaのダミードメインで開発者が所有権 …
Showing the top 5 files — 2 more files (63 regions) not shown.
No evidence locations were recorded for this file. Raw result