| 21 | }, {}); |
| 22 | |
| 23 | function enrichMetadata(meta) { |
| 24 | const res = { |
| 25 | ...meta, |
| 26 | // Add context objects with dummy functions based on metadata |
| 27 | // This allows popup/helpers/utils.js to correctly identify clickable scripts |
| 28 | // Real functions are loaded lazily in index.js |
| 29 | popupScript: meta.contexts?.popup ? { onClick: dummyFn } : undefined, |
| 30 | contentScript: meta.contexts?.content ? { onClick: dummyFn } : undefined, |
| 31 | pageScript: meta.contexts?.page ? { onClick: dummyFn } : undefined, |
| 32 | backgroundScript: meta.contexts?.background |
| 33 | ? { onClick: dummyFn } |
| 34 | : undefined, |
| 35 | }; |
| 36 | if (meta.canAutoRun) { |
| 37 | if (res.contentScript) res.contentScript.onDocumentIdle = dummyFn; |
| 38 | if (res.pageScript) res.pageScript.onDocumentIdle = dummyFn; |
| 39 | if (res.backgroundScript) res.backgroundScript.onDocumentIdle = dummyFn; |
| 40 | } |
| 41 | return res; |
| 42 | } |
| 43 | |
| 44 | const specialTabs = [ |
| 45 | { |