manifest.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import fs from 'node:fs';
  2. import deepmerge from 'deepmerge';
  3. const packageJson = JSON.parse(fs.readFileSync('../package.json', 'utf8'));
  4. const isFirefox = process.env.__FIREFOX__ === 'true';
  5. /**
  6. * If you want to disable the sidePanel, you can delete withSidePanel function and remove the sidePanel HoC on the manifest declaration.
  7. *
  8. * ```js
  9. * const manifest = { // remove `withSidePanel()`
  10. * ```
  11. */
  12. function withSidePanel(manifest) {
  13. // Firefox does not support sidePanel
  14. if (isFirefox) {
  15. return manifest;
  16. }
  17. return deepmerge(manifest, {
  18. side_panel: {
  19. default_path: 'side-panel/index.html',
  20. },
  21. permissions: ['sidePanel'],
  22. });
  23. }
  24. /**
  25. * After changing, please reload the extension at `chrome://extensions`
  26. * @type {chrome.runtime.ManifestV3}
  27. */
  28. const manifest = withSidePanel({
  29. manifest_version: 3,
  30. default_locale: 'en',
  31. /**
  32. * if you want to support multiple languages, you can use the following reference
  33. * https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Internationalization
  34. */
  35. name: '__MSG_extensionName__',
  36. version: packageJson.version,
  37. description: '__MSG_extensionDescription__',
  38. host_permissions: ['<all_urls>'],
  39. permissions: ['storage', 'scripting', 'tabs', 'activeTab', 'debugger'],
  40. options_page: 'options/index.html',
  41. background: {
  42. service_worker: 'background.iife.js',
  43. type: 'module',
  44. },
  45. action: {
  46. default_icon: 'icon-32.png',
  47. },
  48. icons: {
  49. 128: 'icon-128.png',
  50. },
  51. content_scripts: [
  52. {
  53. matches: ['http://*/*', 'https://*/*', '<all_urls>'],
  54. js: ['content/index.iife.js'],
  55. },
  56. ],
  57. web_accessible_resources: [
  58. {
  59. resources: ['*.js', '*.css', '*.svg', 'icon-128.png', 'icon-32.png'],
  60. matches: ['*://*/*'],
  61. },
  62. ],
  63. });
  64. export default manifest;