Files
BewlyBewly/src/manifest.ts
2023-02-08 19:06:29 +08:00

68 lines
2.0 KiB
TypeScript

import fs from 'fs-extra'
import type { Manifest } from 'webextension-polyfill'
import type PkgType from '../package.json'
import { isDev, port, r } from '../scripts/utils'
export async function getManifest() {
const pkg = await fs.readJSON(r('package.json')) as typeof PkgType
// update this file to update this manifest.json
// can also be conditional based on your need
const manifest: Manifest.WebExtensionManifest = {
manifest_version: 3,
name: `${pkg.displayName || pkg.name}${isDev ? ' Dev' : ''}`,
version: pkg.version,
description: pkg.description,
homepage_url: pkg.homepage,
// action: {
// default_icon: './assets/icon-512.png',
// default_popup: './dist/popup/index.html',
// },
// options_ui: {
// page: './dist/options/index.html',
// open_in_tab: true,
// },
background: {
service_worker: './dist/background/index.mjs',
},
icons: {
16: './assets/icon-512.png',
48: './assets/icon-512.png',
128: './assets/icon-512.png',
},
permissions: [
'tabs',
'storage',
'activeTab',
'scripting',
],
host_permissions: ['https://*.bilibili.com/*'],
content_scripts: [
{
matches: ['http://www.bilibili.com/*', 'https://www.bilibili.com/*'],
js: ['./dist/contentScripts/index.global.js'],
// run_at: 'document_start',
match_about_blank: true,
},
],
web_accessible_resources: [
{
resources: ['dist/contentScripts/style.css', 'assets/*'],
matches: ['<all_urls>'],
// matches: ['./assets/*'],
},
],
content_security_policy: {
extension_pages: isDev
// this is required on dev for Vite script to load
? `script-src 'self' http://localhost:${port}; object-src 'self' http://localhost:${port}`
: 'script-src \'self\'; object-src \'self\'',
},
}
if (isDev)
manifest.permissions?.push('webNavigation')
return manifest
}