()
| 30 | } |
| 31 | |
| 32 | async function registerScripts() { |
| 33 | if (typeof chrome.scripting === 'undefined') { |
| 34 | con.error('Custom Domain is not possible'); |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | let domains: domainType[] = await api.settings.getAsync('customDomains'); |
| 39 | |
| 40 | try { |
| 41 | const chibiRepo = await (await ChibiListRepository.getInstance()).init(); |
| 42 | const chibiDomains = await chibiRepo.getPermissions(); |
| 43 | |
| 44 | // Filter out custom domains that exist in chibi |
| 45 | domains = domains.filter(domain => { |
| 46 | return domain.player || !chibiRepo.getList()[domain.page]?.features?.customDomains; |
| 47 | }); |
| 48 | |
| 49 | domains = domains.concat(chibiDomains); |
| 50 | } catch (e) { |
| 51 | logger.error('Could not load chibi permissions', e); |
| 52 | } |
| 53 | |
| 54 | await chrome.scripting.unregisterContentScripts(); |
| 55 | if (domains) { |
| 56 | await Promise.all(domains.map(registerScript)); |
| 57 | } |
| 58 | |
| 59 | const scripts = await chrome.scripting.getRegisteredContentScripts(); |
| 60 | logger.log(scripts); |
| 61 | } |
| 62 | |
| 63 | async function registerScript(domainConfig: domainType) { |
| 64 | if (domainConfig.page === 'hostpermission') return; |
no test coverage detected