Skip to content

Commit

Permalink
Fix #807 - Extract sidePanel config to withSidePanel (#809)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonghakseo <[email protected]>
  • Loading branch information
Jonghakseo and Jonghakseo authored Dec 11, 2024
1 parent 6e57f43 commit fe95293
Showing 1 changed file with 65 additions and 55 deletions.
120 changes: 65 additions & 55 deletions chrome-extension/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,79 @@ const packageJson = JSON.parse(fs.readFileSync('../package.json', 'utf8'));

const isFirefox = process.env.__FIREFOX__ === 'true';

const sidePanelConfig = {
side_panel: {
default_path: 'side-panel/index.html',
},
permissions: ['sidePanel'],
};
/**
* If you want to disable the sidePanel, you can delete withSidePanel function and remove the sidePanel HoC on the manifest declaration.
*
* ```js
* const manifest = { // remove `withSidePanel()`
* ```
*/
function withSidePanel(manifest) {
// Firefox does not support sidePanel
if (isFirefox) {
return manifest;
}
return deepmerge(manifest, {
side_panel: {
default_path: 'side-panel/index.html',
},
permissions: ['sidePanel'],
});
}

/**
* After changing, please reload the extension at `chrome://extensions`
* @type {chrome.runtime.ManifestV3}
*/
const manifest = deepmerge(
{
manifest_version: 3,
default_locale: 'en',
/**
* if you want to support multiple languages, you can use the following reference
* https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Internationalization
*/
name: '__MSG_extensionName__',
version: packageJson.version,
description: '__MSG_extensionDescription__',
host_permissions: ['<all_urls>'],
permissions: ['storage', 'scripting', 'tabs', 'notifications'],
options_page: 'options/index.html',
background: {
service_worker: 'background.iife.js',
type: 'module',
const manifest = withSidePanel({
manifest_version: 3,
default_locale: 'en',
/**
* if you want to support multiple languages, you can use the following reference
* https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Internationalization
*/
name: '__MSG_extensionName__',
version: packageJson.version,
description: '__MSG_extensionDescription__',
host_permissions: ['<all_urls>'],
permissions: ['storage', 'scripting', 'tabs', 'notifications'],
options_page: 'options/index.html',
background: {
service_worker: 'background.iife.js',
type: 'module',
},
action: {
default_popup: 'popup/index.html',
default_icon: 'icon-34.png',
},
chrome_url_overrides: {
newtab: 'new-tab/index.html',
},
icons: {
128: 'icon-128.png',
},
content_scripts: [
{
matches: ['http://*/*', 'https://*/*', '<all_urls>'],
js: ['content/index.iife.js'],
},
action: {
default_popup: 'popup/index.html',
default_icon: 'icon-34.png',
{
matches: ['http://*/*', 'https://*/*', '<all_urls>'],
js: ['content-ui/index.iife.js'],
},
chrome_url_overrides: {
newtab: 'new-tab/index.html',
{
matches: ['http://*/*', 'https://*/*', '<all_urls>'],
js: ['refresh.js'], // for public's HMR(refresh) support
css: ['content.css'], // public folder
},
icons: {
128: 'icon-128.png',
],
devtools_page: 'devtools/index.html',
web_accessible_resources: [
{
resources: ['*.js', '*.css', '*.svg', 'icon-128.png', 'icon-34.png'],
matches: ['*://*/*'],
},
content_scripts: [
{
matches: ['http://*/*', 'https://*/*', '<all_urls>'],
js: ['content/index.iife.js'],
},
{
matches: ['http://*/*', 'https://*/*', '<all_urls>'],
js: ['content-ui/index.iife.js'],
},
{
matches: ['http://*/*', 'https://*/*', '<all_urls>'],
js: ['refresh.js'], // for public's HMR(refresh) support
css: ['content.css'], // public folder
},
],
devtools_page: 'devtools/index.html',
web_accessible_resources: [
{
resources: ['*.js', '*.css', '*.svg', 'icon-128.png', 'icon-34.png'],
matches: ['*://*/*'],
},
],
},
!isFirefox && sidePanelConfig,
);
],
});

export default manifest;

0 comments on commit fe95293

Please sign in to comment.