diff --git a/examples/action-chatgpt/manifest.json b/examples/action-chatgpt/manifest.json index a76f2d30..8fb59d17 100644 --- a/examples/action-chatgpt/manifest.json +++ b/examples/action-chatgpt/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Action ChatGPT Template", + "name": "Action Chatgpt", "description": "An Extension.js example.", "icons": { "16": "images/extension_16.png", diff --git a/examples/config-babel/.gitignore b/examples/action-locales/.gitignore similarity index 100% rename from examples/config-babel/.gitignore rename to examples/action-locales/.gitignore diff --git a/examples/locales/_locales/en/messages.json b/examples/action-locales/_locales/en/messages.json similarity index 100% rename from examples/locales/_locales/en/messages.json rename to examples/action-locales/_locales/en/messages.json diff --git a/examples/locales/_locales/pt_BR/messages.json b/examples/action-locales/_locales/pt_BR/messages.json similarity index 71% rename from examples/locales/_locales/pt_BR/messages.json rename to examples/action-locales/_locales/pt_BR/messages.json index 5dd3828b..9e56f636 100644 --- a/examples/locales/_locales/pt_BR/messages.json +++ b/examples/action-locales/_locales/pt_BR/messages.json @@ -4,7 +4,7 @@ "description": "The title of the extension page" }, "learnMore": { - "message": "Saiba mais sobre a criação de extensões multiplataforma em ", + "message": "Saiba mais sobre como criar extensões multiplataforma em ", "description": "The learn more text" } } diff --git a/examples/locales/action/index.html b/examples/action-locales/action/index.html similarity index 100% rename from examples/locales/action/index.html rename to examples/action-locales/action/index.html diff --git a/examples/action-locales/action/scripts.js b/examples/action-locales/action/scripts.js new file mode 100644 index 00000000..62496da3 --- /dev/null +++ b/examples/action-locales/action/scripts.js @@ -0,0 +1,12 @@ +if ( + process.env.EXTENSION_PUBLIC_BROWSER === 'firefox' || + process.env.EXTENSION_PUBLIC_BROWSER === 'firefox-based' +) { + document.getElementById('title').textContent = chrome.i18n.getMessage('title') + document.getElementById('learnMore').textContent = + chrome.i18n.getMessage('learnMore') +} else { + document.getElementById('title').textContent = chrome.i18n.getMessage('title') + document.getElementById('learnMore').textContent = + chrome.i18n.getMessage('learnMore') +} diff --git a/examples/action-locales/action/styles.css b/examples/action-locales/action/styles.css new file mode 100644 index 00000000..85269ad2 --- /dev/null +++ b/examples/action-locales/action/styles.css @@ -0,0 +1,35 @@ +html { + font-size: 62.5%; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; +} + +body { + width: 300px; + height: 100%; + padding: 1rem; + font-size: 1.35rem; + line-height: 1.618; + color: #c9c9c9; + background-color: #0A0C10; +} + +h1 { + line-height: 1.1; + font-weight: 700; + font-size: 2.7em; + margin-bottom: 1.5rem; +} + +a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; +} + +img { + height: auto; + max-width: 100%; + margin-top: 1rem; + margin-bottom: 1.5rem; +} diff --git a/examples/locales/images/extension_16.png b/examples/action-locales/images/extension_16.png similarity index 100% rename from examples/locales/images/extension_16.png rename to examples/action-locales/images/extension_16.png diff --git a/examples/config-babel/images/extension_48.png b/examples/action-locales/images/extension_48.png similarity index 100% rename from examples/config-babel/images/extension_48.png rename to examples/action-locales/images/extension_48.png diff --git a/examples/locales/manifest.json b/examples/action-locales/manifest.json similarity index 92% rename from examples/locales/manifest.json rename to examples/action-locales/manifest.json index a742a056..be72a436 100644 --- a/examples/locales/manifest.json +++ b/examples/action-locales/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Locales Template", + "name": "Action Locales", "author": "Cezar Augusto", "default_locale": "en", "description": "An Extension.js example.", diff --git a/examples/locales/package.json b/examples/action-locales/package.json similarity index 89% rename from examples/locales/package.json rename to examples/action-locales/package.json index f8ed2d70..ed8be0ed 100644 --- a/examples/locales/package.json +++ b/examples/action-locales/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "locales", + "name": "action-locales", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/content-shadow-dom/public/extension.svg b/examples/action-locales/public/extension.svg similarity index 100% rename from examples/content-shadow-dom/public/extension.svg rename to examples/action-locales/public/extension.svg diff --git a/examples/action/action/scripts.js b/examples/action/action/scripts.js index 7f6946b3..24ed03cc 100644 --- a/examples/action/action/scripts.js +++ b/examples/action/action/scripts.js @@ -1,11 +1 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) +console.log('Hello from the browser action page!') diff --git a/examples/action/action/styles.css b/examples/action/action/styles.css index 69a24316..85269ad2 100644 --- a/examples/action/action/styles.css +++ b/examples/action/action/styles.css @@ -5,52 +5,20 @@ html { } body { - display: flex; - justify-content: center; - align-items: center; - height: calc(100vh - 4rem); - min-width: 300px; - padding: 2rem; - font-size: 1.8rem; + width: 300px; + height: 100%; + padding: 1rem; + font-size: 1.35rem; line-height: 1.618; - max-width: 38em; - margin: auto; color: #c9c9c9; background-color: #0A0C10; } -@media (max-width: 684px) { - body { - font-size: 1.53rem; - } -} - -@media (max-width: 382px) { - body { - font-size: 1.35rem; - } -} - h1 { line-height: 1.1; font-weight: 700; + font-size: 2.7em; margin-bottom: 1.5rem; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; - font-size: 4.7em; -} - -@media (max-width: 684px) { - h1 { - font-size: 2.7em; - } -} - -p { - margin-top: 0px; - margin-bottom: 2.5rem; } a { @@ -59,29 +27,9 @@ a { color: #e5e7eb; } - img { height: auto; max-width: 100%; - margin-top: 0px; - margin-bottom: 2.5rem; -} - -@media (max-width: 684px) { - img { - margin-top: 2rem; - margin-bottom: 1rem; - } -} - -body { - display: flex; - justify-content: center; - align-items: center; - height: calc(100vh - 4rem); + margin-top: 1rem; + margin-bottom: 1.5rem; } - -header > div { - display: flex; - align-items: center; -} \ No newline at end of file diff --git a/examples/action/manifest.json b/examples/action/manifest.json index f6247460..9667a73b 100644 --- a/examples/action/manifest.json +++ b/examples/action/manifest.json @@ -2,12 +2,13 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Action Template", + "name": "Action", "description": "An Extension.js example.", "icons": { "16": "images/extension_16.png", "48": "images/extension_48.png" }, + "permissions": ["storage", "tabs", "activeTab", "scripting"], "action": { "default_popup": "./action/index.html", "default_title": "Action", diff --git a/examples/config-babel/newtab/scripts.js b/examples/config-babel/newtab/scripts.js deleted file mode 100644 index 7f6946b3..00000000 --- a/examples/config-babel/newtab/scripts.js +++ /dev/null @@ -1,11 +0,0 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) diff --git a/examples/config-stylelint/newtab/scripts.js b/examples/config-stylelint/newtab/scripts.js deleted file mode 100644 index 7f6946b3..00000000 --- a/examples/config-stylelint/newtab/scripts.js +++ /dev/null @@ -1,11 +0,0 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) diff --git a/examples/content-css-module/background.js b/examples/content-css-module/background.js deleted file mode 100644 index bfd9ec37..00000000 --- a/examples/content-css-module/background.js +++ /dev/null @@ -1,21 +0,0 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} diff --git a/examples/content-css-module/content/Logo.module.css b/examples/content-css-module/content/Logo.module.css deleted file mode 100644 index b1bcfab7..00000000 --- a/examples/content-css-module/content/Logo.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.logo { - width: 90px; - align-self: flex-start; -} - diff --git a/examples/content-css-module/content/scripts.js b/examples/content-css-module/content/scripts.js deleted file mode 100644 index bdff7938..00000000 --- a/examples/content-css-module/content/scripts.js +++ /dev/null @@ -1,32 +0,0 @@ -import './styles.css' -import styles from './Logo.module.css' - -console.log('hello from content_scripts') - -document.body.innerHTML += ` -
- -

- Change the background-color ⬇ -

- -

- Learn more about creating cross-browser extensions at - https://extension.js.org - -

-
-` - -document.getElementById('colorPicker').addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - color: event.target.value - }) - .catch(console.error) -}) diff --git a/examples/content-css-module/content/styles.css b/examples/content-css-module/content/styles.css deleted file mode 100644 index d837965a..00000000 --- a/examples/content-css-module/content/styles.css +++ /dev/null @@ -1,40 +0,0 @@ -.content_script-box { - background: white; - position: fixed; - right: 0; - bottom: 0; - z-index: 9; - width: 315px; - height: 345px; - margin: 1em; - padding: 1em; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; -} - -.content_script-title { - font-size: 1.85em; - color: #333; - line-height: 1.1; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; - font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; -} - -.content_script-description { - color: #999; -} - -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; -} diff --git a/examples/config-eslint/.gitignore b/examples/content-css-modules/.gitignore similarity index 100% rename from examples/config-eslint/.gitignore rename to examples/content-css-modules/.gitignore diff --git a/examples/content-css-modules/background.js b/examples/content-css-modules/background.js new file mode 100644 index 00000000..798d5018 --- /dev/null +++ b/examples/content-css-modules/background.js @@ -0,0 +1 @@ +console.log('Hello from the background script!') diff --git a/examples/content-css-modules/content/Logo.module.css b/examples/content-css-modules/content/Logo.module.css new file mode 100644 index 00000000..2649a188 --- /dev/null +++ b/examples/content-css-modules/content/Logo.module.css @@ -0,0 +1,5 @@ +.content_logo { + width: 72px; + background: #c9c9c9; + border-radius: 6px; +} \ No newline at end of file diff --git a/examples/content-css-modules/content/scripts.js b/examples/content-css-modules/content/scripts.js new file mode 100644 index 00000000..de85a174 --- /dev/null +++ b/examples/content-css-modules/content/scripts.js @@ -0,0 +1,23 @@ +import './styles.css' +import styles from './Logo.module.css' +import logo from '../images/logo.png' + +console.log('hello from content_scripts') + +document.body.innerHTML += ` +
+ +

+ Welcome to your CSS Modules Extension +

+

+ Learn more about creating cross-browser extensions at + https://extension.js.org + +

+
+ ` diff --git a/examples/content-css-modules/content/styles.css b/examples/content-css-modules/content/styles.css new file mode 100644 index 00000000..14a840f9 --- /dev/null +++ b/examples/content-css-modules/content/styles.css @@ -0,0 +1,33 @@ +.content_script { + color: #c9c9c9; + background-color: #0a0c10; + position: fixed; + right: 0; + bottom: 0; + z-index: 9; + width: 315px; + margin: 1rem; + padding: 2rem 1rem; + display: flex; + flex-direction: column; + gap: 1em; + border-radius: 6px; +} + +.content_title { + font-size: 1.85em; + line-height: 1.1; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; + font-weight: 700; +} + +.content_description { + font-size: small; +} + +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; +} diff --git a/examples/config-eslint/images/extension_48.png b/examples/content-css-modules/images/extension_48.png similarity index 100% rename from examples/config-eslint/images/extension_48.png rename to examples/content-css-modules/images/extension_48.png diff --git a/examples/content-css-modules/images/logo.png b/examples/content-css-modules/images/logo.png new file mode 100644 index 00000000..bb7897fc Binary files /dev/null and b/examples/content-css-modules/images/logo.png differ diff --git a/examples/content-css-module/manifest.json b/examples/content-css-modules/manifest.json similarity index 92% rename from examples/content-css-module/manifest.json rename to examples/content-css-modules/manifest.json index 1c7990d1..b9cc4207 100644 --- a/examples/content-css-module/manifest.json +++ b/examples/content-css-modules/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content CSS Module Template", + "name": "Content Scripts Css Modules", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-css-module/package.json b/examples/content-css-modules/package.json similarity index 86% rename from examples/content-css-module/package.json rename to examples/content-css-modules/package.json index 081b6288..3790633a 100644 --- a/examples/content-css-module/package.json +++ b/examples/content-css-modules/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "content-css-module", + "name": "content-css-modules", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/config-lint/public/logo.svg b/examples/content-css-modules/public/logo.svg similarity index 100% rename from examples/config-lint/public/logo.svg rename to examples/content-css-modules/public/logo.svg diff --git a/examples/content-css-module/template.spec.ts b/examples/content-css-modules/template.spec.ts similarity index 71% rename from examples/content-css-module/template.spec.ts rename to examples/content-css-modules/template.spec.ts index b5ab2661..f093171a 100644 --- a/examples/content-css-module/template.spec.ts +++ b/examples/content-css-modules/template.spec.ts @@ -2,7 +2,7 @@ import path from 'path' import {execSync} from 'child_process' import {extensionFixtures} from '../extension-fixtures' -const exampleDir = 'examples/content-css-module' +const exampleDir = 'examples/content-css-modules' const pathToExtension = path.join(__dirname, `dist/chrome`) const test = extensionFixtures(pathToExtension, true) @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-env/background.ts b/examples/content-env/background.ts index 265bf0f8..798d5018 100644 --- a/examples/content-env/background.ts +++ b/examples/content-env/background.ts @@ -1,26 +1 @@ -console.log('hello from background script') - -// eslint-disable-next-line no-undef -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab?.id) - } -}) - -function changeBackgroundColor(color: string, tabId: number | undefined) { - if (!tabId) { - return - } - - chrome.scripting - .executeScript({ - target: {tabId}, - func: setContentPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setContentPageBackgroundColor(color: string) { - document.body.style.backgroundColor = color -} +console.log('Hello from the background script!') diff --git a/examples/content-env/content/scripts.ts b/examples/content-env/content/scripts.ts index d33abad2..7198fab9 100644 --- a/examples/content-env/content/scripts.ts +++ b/examples/content-env/content/scripts.ts @@ -1,4 +1,5 @@ import './styles.css' +import logo from '../images/logo.png' console.log( 'hello from content_scripts', @@ -6,18 +7,14 @@ console.log( ) // Check if the content has already been added -if (!document.querySelector('.content_script-box')) { - document.body.innerHTML += ` -
-
- -
-

${process.env.EXTENSION_PUBLIC_DESCRIPTION_TEXT}

-

- Change the background-color ⬇ +document.body.innerHTML += ` +
+ +

${process.env.EXTENSION_PUBLIC_DESCRIPTION_TEXT}

+

+ Welcome to your .env Extension

- -

+

Learn more about creating cross-browser extensions at

` -} - -const colorPicker = document.getElementById('colorPicker') - -// Add the event listener only if it hasn't been added yet -if (colorPicker && !colorPicker.hasAttribute('data-listener')) { - colorPicker.addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - // @ts-expect-error - color: event.target?.value - }) - .catch(console.error) - }) - - // Mark the element to avoid adding the listener again - colorPicker.setAttribute('data-listener', 'true') -} diff --git a/examples/content-env/content/styles.css b/examples/content-env/content/styles.css index 6e8dd596..2049a65c 100644 --- a/examples/content-env/content/styles.css +++ b/examples/content-env/content/styles.css @@ -1,52 +1,37 @@ -.content_script-box { - background: white; +.content_script { + color: #c9c9c9; + background-color: #0a0c10; position: fixed; right: 0; bottom: 0; z-index: 9; width: 315px; - height: 375px; - margin: 1em; - padding: 1em; + margin: 1rem; + padding: 2rem 1rem; display: flex; - align-items: center; - justify-content: center; flex-direction: column; gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; + border-radius: 6px; } -.content_script-logo-box { - display: flex; - align-items: center; - justify-content: center; - gap: 1em; -} - -.content_script-logo { - width: 90px; - align-self: flex-start; +.content_logo { + width: 72px; } -.content_script-title { +.content_title { font-size: 1.85em; - color: #333; line-height: 1.1; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; } -.content_script-description { - color: #999; +.content_description { + font-size: small; } -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; } diff --git a/examples/content-env/images/logo.png b/examples/content-env/images/logo.png new file mode 100644 index 00000000..5266e487 Binary files /dev/null and b/examples/content-env/images/logo.png differ diff --git a/examples/content-env/manifest.json b/examples/content-env/manifest.json index 20326e83..e2baf7dd 100644 --- a/examples/content-env/manifest.json +++ b/examples/content-env/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts .env Template", + "name": "Content Scripts Env", "description": "$EXTENSION_PUBLIC_DESCRIPTION_TEXT", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-env/template.spec.ts b/examples/content-env/template.spec.ts index da53f3c0..5f4bf797 100644 --- a/examples/content-env/template.spec.ts +++ b/examples/content-env/template.spec.ts @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-esm/background.mjs b/examples/content-esm/background.mjs index 062b03a0..44ac824e 100644 --- a/examples/content-esm/background.mjs +++ b/examples/content-esm/background.mjs @@ -1,21 +1 @@ console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = `${color} !important;` -} diff --git a/examples/content-esm/content/contentComponent.mjs b/examples/content-esm/content/contentComponent.mjs index 5851ff6b..7ff2ecc8 100644 --- a/examples/content-esm/content/contentComponent.mjs +++ b/examples/content-esm/content/contentComponent.mjs @@ -1,12 +1,9 @@ -const contentComponent = `
-
- -
-

- Change the background-color ⬇ -

- -

+import logo from '../images/logo.png' + +const contentComponent = `

+ +

Welcome to your ESModule Extension

+

Learn more about creating cross-browser extensions at { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - color: event.target.value - }) - .catch(console.error) -}) diff --git a/examples/content-esm/content/styles.css b/examples/content-esm/content/styles.css index 0deb61ca..2049a65c 100644 --- a/examples/content-esm/content/styles.css +++ b/examples/content-esm/content/styles.css @@ -1,62 +1,37 @@ -.content_script-box { - background: white; +.content_script { + color: #c9c9c9; + background-color: #0a0c10; position: fixed; right: 0; bottom: 0; z-index: 9; width: 315px; - height: 345px; - margin: 1em; - padding: 1em; + margin: 1rem; + padding: 2rem 1rem; display: flex; - align-items: center; - justify-content: center; flex-direction: column; gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; - color: #333; + border-radius: 6px; } -.content_script-header { - display: flex; - align-items: center; - justify-content: left; - gap: 1em; -} - -.content_script-logo { - width: 90px; - align-self: flex-start; - filter: grayscale(1); - transition: - filter 2s, - border-color 2s; -} - -.content_script-logo:hover { - filter: grayscale(0); - border-color: aquamarine; +.content_logo { + width: 72px; } -.content_script-title { +.content_title { font-size: 1.85em; - color: #333; line-height: 1.1; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; } -.content_script-description { - color: #999; +.content_description { + font-size: small; } -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; } diff --git a/examples/content-esm/images/logo.png b/examples/content-esm/images/logo.png new file mode 100644 index 00000000..7b5ffab2 Binary files /dev/null and b/examples/content-esm/images/logo.png differ diff --git a/examples/content-esm/manifest.json b/examples/content-esm/manifest.json index c01840f2..e40512b6 100644 --- a/examples/content-esm/manifest.json +++ b/examples/content-esm/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts ESM Template", + "name": "Content Scripts Esm", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-esm/template.spec.mjs b/examples/content-esm/template.spec.mjs index 337a7d73..44980d2a 100644 --- a/examples/content-esm/template.spec.mjs +++ b/examples/content-esm/template.spec.mjs @@ -17,28 +17,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name .content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-extension-config/content/ContentApp.tsx b/examples/content-extension-config/content/ContentApp.tsx index 245ca43e..da59c665 100644 --- a/examples/content-extension-config/content/ContentApp.tsx +++ b/examples/content-extension-config/content/ContentApp.tsx @@ -57,7 +57,8 @@ export default function ContentApp() { />

- This is a content script running React, TypeScript, and Tailwind.css + This is a content script running React, TypeScript, Tailwind.css, + and a custom extension.config.js file.

Learn more about creating cross-browser extensions by{' '} diff --git a/examples/content-extension-config/manifest.json b/examples/content-extension-config/manifest.json index 22e3b372..5086eab4 100644 --- a/examples/content-extension-config/manifest.json +++ b/examples/content-extension-config/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "content-extension-config", + "name": "Content Scripts Extension Config", "description": "An Extension.js example.", "background": { "chromium:service_worker": "background.ts", diff --git a/examples/content-extension-config/template.spec.ts b/examples/content-extension-config/template.spec.ts index e5c572c2..1ddeb9d9 100644 --- a/examples/content-extension-config/template.spec.ts +++ b/examples/content-extension-config/template.spec.ts @@ -23,11 +23,7 @@ test('should exist an element with the class name extension-root', async ({ test('should exist an h2 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') const h2 = page.locator('#extension-root h2') - await test - .expect(h2) - .toHaveText( - 'This is a content script running React, TypeScript, and Tailwind.css' - ) + await test.expect(h2).toContainText('This is a content script') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/content-less-module/background.js b/examples/content-less-module/background.js deleted file mode 100644 index bfd9ec37..00000000 --- a/examples/content-less-module/background.js +++ /dev/null @@ -1,21 +0,0 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} diff --git a/examples/content-less-module/content/Logo.module.less b/examples/content-less-module/content/Logo.module.less deleted file mode 100644 index abc7cf93..00000000 --- a/examples/content-less-module/content/Logo.module.less +++ /dev/null @@ -1,18 +0,0 @@ -.logo { - background: white; - width: 90px; - align-self: flex-start; - border: 4px solid; - border-color: #ccc; - border-radius: 24px; - filter: grayscale(1); - transition: - filter 2s, - border-color 2s; -} - -.logo:hover { - filter: grayscale(0); - border-color: aquamarine; -} - diff --git a/examples/content-less-module/content/scripts.js b/examples/content-less-module/content/scripts.js deleted file mode 100644 index d42223db..00000000 --- a/examples/content-less-module/content/scripts.js +++ /dev/null @@ -1,32 +0,0 @@ -import './styles.less' -import styles from './Logo.module.less' - -console.log('hello from content_scripts') - -document.body.innerHTML += ` -

-` - -document.getElementById('colorPicker').addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - color: event.target.value - }) - .catch(console.error) -}) diff --git a/examples/content-less-module/content/styles.less b/examples/content-less-module/content/styles.less deleted file mode 100644 index d837965a..00000000 --- a/examples/content-less-module/content/styles.less +++ /dev/null @@ -1,40 +0,0 @@ -.content_script-box { - background: white; - position: fixed; - right: 0; - bottom: 0; - z-index: 9; - width: 315px; - height: 345px; - margin: 1em; - padding: 1em; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; -} - -.content_script-title { - font-size: 1.85em; - color: #333; - line-height: 1.1; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; - font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; -} - -.content_script-description { - color: #999; -} - -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; -} diff --git a/examples/config-lint/.gitignore b/examples/content-less-modules/.gitignore similarity index 100% rename from examples/config-lint/.gitignore rename to examples/content-less-modules/.gitignore diff --git a/examples/content-less-modules/background.js b/examples/content-less-modules/background.js new file mode 100644 index 00000000..798d5018 --- /dev/null +++ b/examples/content-less-modules/background.js @@ -0,0 +1 @@ +console.log('Hello from the background script!') diff --git a/examples/content-less-modules/content/Logo.module.less b/examples/content-less-modules/content/Logo.module.less new file mode 100644 index 00000000..22e2f825 --- /dev/null +++ b/examples/content-less-modules/content/Logo.module.less @@ -0,0 +1,3 @@ +.logo { + width: 72px; +} \ No newline at end of file diff --git a/examples/content-less-modules/content/scripts.js b/examples/content-less-modules/content/scripts.js new file mode 100644 index 00000000..5f264c50 --- /dev/null +++ b/examples/content-less-modules/content/scripts.js @@ -0,0 +1,23 @@ +import './styles.less' +import styles from './Logo.module.less' +import logo from '../images/logo.svg' + +console.log('hello from content_scripts') + +document.body.innerHTML += ` +
+ +

+ Welcome to your LESS Modules Extension +

+

+ Learn more about creating cross-browser extensions at + https://extension.js.org + +

+
+` diff --git a/examples/content-less-modules/content/styles.less b/examples/content-less-modules/content/styles.less new file mode 100644 index 00000000..d1548afe --- /dev/null +++ b/examples/content-less-modules/content/styles.less @@ -0,0 +1,37 @@ +.content_script { + color: #c9c9c9; + background-color: #0a0c10; + position: fixed; + right: 0; + bottom: 0; + z-index: 9; + width: 315px; + margin: 1rem; + padding: 2rem 1rem; + display: flex; + flex-direction: column; + gap: 1em; + border-radius: 6px; +} + +.content_logo { + width: 72px; +} + +.content_title { + font-size: 1.85em; + line-height: 1.1; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; + font-weight: 700; +} + +.content_description { + font-size: small; +} + +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; +} \ No newline at end of file diff --git a/examples/config-lint/images/extension_48.png b/examples/content-less-modules/images/extension_48.png similarity index 100% rename from examples/config-lint/images/extension_48.png rename to examples/content-less-modules/images/extension_48.png diff --git a/examples/content-less-modules/images/logo.svg b/examples/content-less-modules/images/logo.svg new file mode 100644 index 00000000..007f2642 --- /dev/null +++ b/examples/content-less-modules/images/logo.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/content-less-module/manifest.json b/examples/content-less-modules/manifest.json similarity index 92% rename from examples/content-less-module/manifest.json rename to examples/content-less-modules/manifest.json index 10053614..e6872b68 100644 --- a/examples/content-less-module/manifest.json +++ b/examples/content-less-modules/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts LESS Module", + "name": "Content Scripts Less Modules", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-less-module/package.json b/examples/content-less-modules/package.json similarity index 88% rename from examples/content-less-module/package.json rename to examples/content-less-modules/package.json index aa5ed76c..3ff3ef9a 100644 --- a/examples/content-less-module/package.json +++ b/examples/content-less-modules/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "content-less-module", + "name": "content-less-modules", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/content-less-modules/public/logo.svg b/examples/content-less-modules/public/logo.svg new file mode 100644 index 00000000..007f2642 --- /dev/null +++ b/examples/content-less-modules/public/logo.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/content-sass-module/template.spec.ts b/examples/content-less-modules/template.spec.ts similarity index 71% rename from examples/content-sass-module/template.spec.ts rename to examples/content-less-modules/template.spec.ts index 7fcd9357..5411bca5 100644 --- a/examples/content-sass-module/template.spec.ts +++ b/examples/content-less-modules/template.spec.ts @@ -2,7 +2,7 @@ import path from 'path' import {execSync} from 'child_process' import {extensionFixtures} from '../extension-fixtures' -const exampleDir = 'examples/content-sass-module' +const exampleDir = 'examples/content-less-modules' const pathToExtension = path.join(__dirname, `dist/chrome`) const test = extensionFixtures(pathToExtension, true) @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-less/background.js b/examples/content-less/background.js index bfd9ec37..798d5018 100644 --- a/examples/content-less/background.js +++ b/examples/content-less/background.js @@ -1,21 +1 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} +console.log('Hello from the background script!') diff --git a/examples/content-less/content/scripts.js b/examples/content-less/content/scripts.js index 1a1116ea..5adca586 100644 --- a/examples/content-less/content/scripts.js +++ b/examples/content-less/content/scripts.js @@ -1,15 +1,15 @@ import './styles.less' +import logo from '../images/logo.svg' console.log('hello from content_scripts') document.body.innerHTML += ` -
- -

- Change the background-color ⬇ +
+ +

+ Welcome to your LESS Extension

- -

+

Learn more about creating cross-browser extensions at

` - -document.getElementById('colorPicker').addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - color: event.target.value - }) - .catch(console.error) -}) diff --git a/examples/content-less/content/styles.less b/examples/content-less/content/styles.less index 092f3152..d1548afe 100644 --- a/examples/content-less/content/styles.less +++ b/examples/content-less/content/styles.less @@ -1,45 +1,37 @@ -.content_script-box { - background: white; +.content_script { + color: #c9c9c9; + background-color: #0a0c10; position: fixed; right: 0; bottom: 0; z-index: 9; width: 315px; - height: 345px; - margin: 1em; - padding: 1em; + margin: 1rem; + padding: 2rem 1rem; display: flex; - align-items: center; - justify-content: center; flex-direction: column; gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; + border-radius: 6px; } -.content_script-logo { - width: 90px; - align-self: flex-start; +.content_logo { + width: 72px; } -.content_script-title { +.content_title { font-size: 1.85em; - color: #333; line-height: 1.1; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; } -.content_script-description { - color: #999; +.content_description { + font-size: small; } -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; -} +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; +} \ No newline at end of file diff --git a/examples/content-less/images/logo.svg b/examples/content-less/images/logo.svg new file mode 100644 index 00000000..007f2642 --- /dev/null +++ b/examples/content-less/images/logo.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/content-less/manifest.json b/examples/content-less/manifest.json index c8ff9cc7..e5db08be 100644 --- a/examples/content-less/manifest.json +++ b/examples/content-less/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts Less Template", + "name": "Content Scripts Less", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-less/public/logo.svg b/examples/content-less/public/logo.svg index ebe0773a..007f2642 100644 --- a/examples/content-less/public/logo.svg +++ b/examples/content-less/public/logo.svg @@ -1,3 +1,33 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/content-less/template.spec.ts b/examples/content-less/template.spec.ts index 2ee82485..416afb98 100644 --- a/examples/content-less/template.spec.ts +++ b/examples/content-less/template.spec.ts @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-main-world/content/scripts.js b/examples/content-main-world/content/scripts.js index eed040cd..da28aa76 100644 --- a/examples/content-main-world/content/scripts.js +++ b/examples/content-main-world/content/scripts.js @@ -2,12 +2,12 @@ import './styles.css' import logo from '../images/extension.svg' document.body.innerHTML += ` -
- -

+
+ +

Main World

-

+

Learn more about creating cross-browser extensions at { config.output.publicPath = diff --git a/examples/content-main-world/manifest.json b/examples/content-main-world/manifest.json index 03b3bcbb..92d13a06 100644 --- a/examples/content-main-world/manifest.json +++ b/examples/content-main-world/manifest.json @@ -3,7 +3,7 @@ "manifest_version": 3, "version": "0.0.1", "name": "Content Scripts Main World", - "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoVedbjewIXu8lq/o5zGlS8R38LeejoRr2U6hAH09X6b+BbCXWj6sjQN6FUT1oPGAq2GzDdRJeBpCB2mViUCeaJWOBoKpWD6PRYHAsiHUsyis/cDjbYDjKsXvOw7YhlkQQYgqYRtT+/JdOzM01OlWVugmzLkdSbv7GQSfcFkCOK6fSWuc0Dqt/FkJ7fMEWr8JuE51ATBI50SCt4bg6YZqmNUprxXpA563Iim1Nt5JC6r/LHMD9bqqH0XiVypouq9IHO8VA/YLm/QaK4K55uDxaxFcRd5/mjnywji6NlGSXzBW1cfO9J72S3UG2guTFoHjXtkxvN0bj208kkaihePIKwIDAQAB", + "chromium:key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoVedbjewIXu8lq/o5zGlS8R38LeejoRr2U6hAH09X6b+BbCXWj6sjQN6FUT1oPGAq2GzDdRJeBpCB2mViUCeaJWOBoKpWD6PRYHAsiHUsyis/cDjbYDjKsXvOw7YhlkQQYgqYRtT+/JdOzM01OlWVugmzLkdSbv7GQSfcFkCOK6fSWuc0Dqt/FkJ7fMEWr8JuE51ATBI50SCt4bg6YZqmNUprxXpA563Iim1Nt5JC6r/LHMD9bqqH0XiVypouq9IHO8VA/YLm/QaK4K55uDxaxFcRd5/mjnywji6NlGSXzBW1cfO9J72S3UG2guTFoHjXtkxvN0bj208kkaihePIKwIDAQAB", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-main-world/template.spec.ts b/examples/content-main-world/template.spec.ts index 7d49a132..df67c635 100644 --- a/examples/content-main-world/template.spec.ts +++ b/examples/content-main-world/template.spec.ts @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Main World') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Main World') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(255, 255, 255)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-preact/template.spec.ts b/examples/content-preact/template.spec.ts index 271fd789..557fb745 100644 --- a/examples/content-preact/template.spec.ts +++ b/examples/content-preact/template.spec.ts @@ -25,7 +25,7 @@ test('should exist an h2 element with specified content', async ({page}) => { const h2 = page.locator('#extension-root h2') await test .expect(h2) - .toHaveText( + .toContainText( 'This is a content script running Preact, TypeScript, and Tailwind.css.' ) }) diff --git a/examples/content-react-svgr/content/ContentApp.tsx b/examples/content-react-svgr/content/ContentApp.tsx index 0fb6dc1a..4eec3959 100644 --- a/examples/content-react-svgr/content/ContentApp.tsx +++ b/examples/content-react-svgr/content/ContentApp.tsx @@ -53,7 +53,7 @@ export default function ContentApp() { />

- This is a content script running React, TypeScript, and Tailwind.css + This is a content script running React SVGR

Learn more about creating cross-browser extensions by{' '} diff --git a/examples/content-react-svgr/manifest.json b/examples/content-react-svgr/manifest.json index 582f149d..9eeb99f5 100644 --- a/examples/content-react-svgr/manifest.json +++ b/examples/content-react-svgr/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "content-react-svgr", + "name": "Content Scripts React SVGR", "description": "An Extension.js example.", "background": { "chromium:service_worker": "background.ts", diff --git a/examples/content-react/template.spec.ts b/examples/content-react/template.spec.ts index a7aa6406..375ed2c7 100644 --- a/examples/content-react/template.spec.ts +++ b/examples/content-react/template.spec.ts @@ -23,11 +23,7 @@ test('should exist an element with the class name extension-root', async ({ test('should exist an h2 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') const h2 = page.locator('#extension-root h2') - await test - .expect(h2) - .toHaveText( - 'This is a content script running React, TypeScript, and Tailwind.css' - ) + await test.expect(h2).toContainText('This is a content script') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/content-sass-module/background.js b/examples/content-sass-module/background.js deleted file mode 100644 index bfd9ec37..00000000 --- a/examples/content-sass-module/background.js +++ /dev/null @@ -1,21 +0,0 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} diff --git a/examples/content-sass-module/content/Logo.module.scss b/examples/content-sass-module/content/Logo.module.scss deleted file mode 100644 index abc7cf93..00000000 --- a/examples/content-sass-module/content/Logo.module.scss +++ /dev/null @@ -1,18 +0,0 @@ -.logo { - background: white; - width: 90px; - align-self: flex-start; - border: 4px solid; - border-color: #ccc; - border-radius: 24px; - filter: grayscale(1); - transition: - filter 2s, - border-color 2s; -} - -.logo:hover { - filter: grayscale(0); - border-color: aquamarine; -} - diff --git a/examples/content-sass-module/content/scripts.js b/examples/content-sass-module/content/scripts.js deleted file mode 100644 index 6f758071..00000000 --- a/examples/content-sass-module/content/scripts.js +++ /dev/null @@ -1,32 +0,0 @@ -import './styles.scss' -import styles from './Logo.module.scss' - -console.log('hello from content_scripts') - -document.body.innerHTML += ` -

-` - -document.getElementById('colorPicker').addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - color: event.target.value - }) - .catch(console.error) -}) diff --git a/examples/content-sass-module/content/styles.scss b/examples/content-sass-module/content/styles.scss deleted file mode 100644 index d837965a..00000000 --- a/examples/content-sass-module/content/styles.scss +++ /dev/null @@ -1,40 +0,0 @@ -.content_script-box { - background: white; - position: fixed; - right: 0; - bottom: 0; - z-index: 9; - width: 315px; - height: 345px; - margin: 1em; - padding: 1em; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; -} - -.content_script-title { - font-size: 1.85em; - color: #333; - line-height: 1.1; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; - font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; -} - -.content_script-description { - color: #999; -} - -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; -} diff --git a/examples/config-prettier/.gitignore b/examples/content-sass-modules/.gitignore similarity index 100% rename from examples/config-prettier/.gitignore rename to examples/content-sass-modules/.gitignore diff --git a/examples/content-sass-modules/background.js b/examples/content-sass-modules/background.js new file mode 100644 index 00000000..798d5018 --- /dev/null +++ b/examples/content-sass-modules/background.js @@ -0,0 +1 @@ +console.log('Hello from the background script!') diff --git a/examples/content-sass-modules/content/Logo.module.scss b/examples/content-sass-modules/content/Logo.module.scss new file mode 100644 index 00000000..1ad612e4 --- /dev/null +++ b/examples/content-sass-modules/content/Logo.module.scss @@ -0,0 +1,4 @@ +.logo { + width: 72px; +} + diff --git a/examples/content-sass-modules/content/scripts.js b/examples/content-sass-modules/content/scripts.js new file mode 100644 index 00000000..1c9f6a5c --- /dev/null +++ b/examples/content-sass-modules/content/scripts.js @@ -0,0 +1,23 @@ +import './styles.scss' +import styles from './Logo.module.scss' +import logo from '../images/logo.svg' + +console.log('hello from content_scripts') + +document.body.innerHTML += ` +
+ +

+ Welcome to your Sass Modules Extension +

+

+ Learn more about creating cross-browser extensions at + https://extension.js.org + +

+
+` diff --git a/examples/content-sass-modules/content/styles.scss b/examples/content-sass-modules/content/styles.scss new file mode 100644 index 00000000..d1548afe --- /dev/null +++ b/examples/content-sass-modules/content/styles.scss @@ -0,0 +1,37 @@ +.content_script { + color: #c9c9c9; + background-color: #0a0c10; + position: fixed; + right: 0; + bottom: 0; + z-index: 9; + width: 315px; + margin: 1rem; + padding: 2rem 1rem; + display: flex; + flex-direction: column; + gap: 1em; + border-radius: 6px; +} + +.content_logo { + width: 72px; +} + +.content_title { + font-size: 1.85em; + line-height: 1.1; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; + font-weight: 700; +} + +.content_description { + font-size: small; +} + +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; +} \ No newline at end of file diff --git a/examples/config-prettier/images/extension_48.png b/examples/content-sass-modules/images/extension_48.png similarity index 100% rename from examples/config-prettier/images/extension_48.png rename to examples/content-sass-modules/images/extension_48.png diff --git a/examples/content-sass-modules/images/logo.svg b/examples/content-sass-modules/images/logo.svg new file mode 100644 index 00000000..f3f4a52e --- /dev/null +++ b/examples/content-sass-modules/images/logo.svg @@ -0,0 +1,34 @@ + + + + + + + diff --git a/examples/content-sass-module/manifest.json b/examples/content-sass-modules/manifest.json similarity index 92% rename from examples/content-sass-module/manifest.json rename to examples/content-sass-modules/manifest.json index cde5bbc3..b0a28f9a 100644 --- a/examples/content-sass-module/manifest.json +++ b/examples/content-sass-modules/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts SASS Module", + "name": "Content Scripts Sass Modules", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-sass-module/package.json b/examples/content-sass-modules/package.json similarity index 88% rename from examples/content-sass-module/package.json rename to examples/content-sass-modules/package.json index a7bb0bdd..67f13273 100644 --- a/examples/content-sass-module/package.json +++ b/examples/content-sass-modules/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "content-sass-module", + "name": "content-sass-modules", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/content-sass-modules/public/logo.svg b/examples/content-sass-modules/public/logo.svg new file mode 100644 index 00000000..f3f4a52e --- /dev/null +++ b/examples/content-sass-modules/public/logo.svg @@ -0,0 +1,34 @@ + + + + + + + diff --git a/examples/content-less-module/template.spec.ts b/examples/content-sass-modules/template.spec.ts similarity index 71% rename from examples/content-less-module/template.spec.ts rename to examples/content-sass-modules/template.spec.ts index 55904125..dbd9824c 100644 --- a/examples/content-less-module/template.spec.ts +++ b/examples/content-sass-modules/template.spec.ts @@ -2,7 +2,7 @@ import path from 'path' import {execSync} from 'child_process' import {extensionFixtures} from '../extension-fixtures' -const exampleDir = 'examples/content-less-module' +const exampleDir = 'examples/content-sass-modules' const pathToExtension = path.join(__dirname, `dist/chrome`) const test = extensionFixtures(pathToExtension, true) @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-sass/background.js b/examples/content-sass/background.js index bfd9ec37..798d5018 100644 --- a/examples/content-sass/background.js +++ b/examples/content-sass/background.js @@ -1,21 +1 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} +console.log('Hello from the background script!') diff --git a/examples/content-sass/content/scripts.js b/examples/content-sass/content/scripts.js index 847d54fd..6c6f8a75 100644 --- a/examples/content-sass/content/scripts.js +++ b/examples/content-sass/content/scripts.js @@ -1,15 +1,16 @@ import './styles.scss' +import logo from '../images/logo.svg' console.log('hello from content_scripts') +// Check if the content has already been added document.body.innerHTML += ` -
- -

- Change the background-color ⬇ +
+ +

+ Welcome to your Sass Extension

- -

+

Learn more about creating cross-browser extensions at

-` - -document.getElementById('colorPicker').addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - color: event.target.value - }) - .catch(console.error) -}) + ` diff --git a/examples/content-sass/content/styles.scss b/examples/content-sass/content/styles.scss index 092f3152..d1548afe 100644 --- a/examples/content-sass/content/styles.scss +++ b/examples/content-sass/content/styles.scss @@ -1,45 +1,37 @@ -.content_script-box { - background: white; +.content_script { + color: #c9c9c9; + background-color: #0a0c10; position: fixed; right: 0; bottom: 0; z-index: 9; width: 315px; - height: 345px; - margin: 1em; - padding: 1em; + margin: 1rem; + padding: 2rem 1rem; display: flex; - align-items: center; - justify-content: center; flex-direction: column; gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; + border-radius: 6px; } -.content_script-logo { - width: 90px; - align-self: flex-start; +.content_logo { + width: 72px; } -.content_script-title { +.content_title { font-size: 1.85em; - color: #333; line-height: 1.1; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; } -.content_script-description { - color: #999; +.content_description { + font-size: small; } -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; -} +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; +} \ No newline at end of file diff --git a/examples/content-sass/images/logo.svg b/examples/content-sass/images/logo.svg new file mode 100644 index 00000000..f3f4a52e --- /dev/null +++ b/examples/content-sass/images/logo.svg @@ -0,0 +1,34 @@ + + + + + + + diff --git a/examples/content-sass/manifest.json b/examples/content-sass/manifest.json index 6289845a..49a99874 100644 --- a/examples/content-sass/manifest.json +++ b/examples/content-sass/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "content-sass", + "name": "Content Scripts Sass", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-sass/public/logo.svg b/examples/content-sass/public/logo.svg index ebe0773a..f3f4a52e 100644 --- a/examples/content-sass/public/logo.svg +++ b/examples/content-sass/public/logo.svg @@ -1,3 +1,34 @@ - - + + + + + + diff --git a/examples/content-sass/template.spec.ts b/examples/content-sass/template.spec.ts index 101fc820..acd1e079 100644 --- a/examples/content-sass/template.spec.ts +++ b/examples/content-sass/template.spec.ts @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-shadow-dom/background.js b/examples/content-shadow-dom/background.js deleted file mode 100644 index bfd9ec37..00000000 --- a/examples/content-shadow-dom/background.js +++ /dev/null @@ -1,21 +0,0 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} diff --git a/examples/content-shadow-dom/content/content.js b/examples/content-shadow-dom/content/content.js deleted file mode 100644 index 8aaa8ec7..00000000 --- a/examples/content-shadow-dom/content/content.js +++ /dev/null @@ -1,45 +0,0 @@ -import tailwindBg from '../images/tailwind_bg.png' -import tailwindLogo from '../images/tailwind.png' -import chromeWindowBg from '../images/chromeWindow.png' - -export function getContentHtml() { - return ` -
-
-
-
- - - -
-
-
-
- Tailwind logo -
-

- This is a content script running Tailwind.css. -

-
-
- Chrome window screenshot -
-
-
- ` -} diff --git a/examples/content-shadow-dom/content/scripts.js b/examples/content-shadow-dom/content/scripts.js deleted file mode 100644 index 772d5bec..00000000 --- a/examples/content-shadow-dom/content/scripts.js +++ /dev/null @@ -1,8 +0,0 @@ -// TODO: This does nothing yet - -import './styles.css' -import {getContentHtml} from './content' - -console.log('hello from content_scripts') - -document.body.innerHTML += `
${getContentHtml()}
` diff --git a/examples/content-shadow-dom/content/styles.css b/examples/content-shadow-dom/content/styles.css deleted file mode 100644 index dc79ebb5..00000000 --- a/examples/content-shadow-dom/content/styles.css +++ /dev/null @@ -1,10 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -#extension-root { - position: fixed; - bottom: 0; - right: 0; - z-index: 99999; -} diff --git a/examples/content-shadow-dom/images/chromeWindow.png b/examples/content-shadow-dom/images/chromeWindow.png deleted file mode 100644 index d70571be..00000000 Binary files a/examples/content-shadow-dom/images/chromeWindow.png and /dev/null differ diff --git a/examples/content-shadow-dom/images/react.png b/examples/content-shadow-dom/images/react.png deleted file mode 100644 index 9080fddd..00000000 Binary files a/examples/content-shadow-dom/images/react.png and /dev/null differ diff --git a/examples/content-shadow-dom/images/tailwind.png b/examples/content-shadow-dom/images/tailwind.png deleted file mode 100644 index 83ed5e12..00000000 Binary files a/examples/content-shadow-dom/images/tailwind.png and /dev/null differ diff --git a/examples/content-shadow-dom/images/tailwind_bg.png b/examples/content-shadow-dom/images/tailwind_bg.png deleted file mode 100644 index edc40be8..00000000 Binary files a/examples/content-shadow-dom/images/tailwind_bg.png and /dev/null differ diff --git a/examples/content-shadow-dom/manifest.json b/examples/content-shadow-dom/manifest.json deleted file mode 100644 index d4727084..00000000 --- a/examples/content-shadow-dom/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/chrome-manifest.json", - "manifest_version": 3, - "version": "0.0.1", - "name": "Content Scripts Shadow DOM Template", - "description": "An Extension.js example.", - "icons": { - "48": "images/extension_48.png" - }, - "permissions": ["activeTab", "scripting"], - "host_permissions": [""], - "background": { - "chromium:service_worker": "background.js", - "firefox:scripts": ["background.js"] - }, - "content_scripts": [ - { - "matches": [""], - "js": ["content/scripts.js"] - } - ] -} diff --git a/examples/content-shadow-dom/postcss.config.js b/examples/content-shadow-dom/postcss.config.js deleted file mode 100644 index 85f717cc..00000000 --- a/examples/content-shadow-dom/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {} - } -} diff --git a/examples/content-shadow-dom/public/logo.svg b/examples/content-shadow-dom/public/logo.svg deleted file mode 100644 index ebe0773a..00000000 --- a/examples/content-shadow-dom/public/logo.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/content-shadow-dom/tailwind.config.js b/examples/content-shadow-dom/tailwind.config.js deleted file mode 100644 index b0814971..00000000 --- a/examples/content-shadow-dom/tailwind.config.js +++ /dev/null @@ -1,8 +0,0 @@ -/** @type {import('tailwindcss').Config} */ -module.exports = { - content: ['./content/**/*.js'], - theme: { - extend: {} - }, - plugins: [] -} diff --git a/examples/content-shadow-dom/template.spec.ts b/examples/content-shadow-dom/template.spec.ts deleted file mode 100644 index 2a1e3b50..00000000 --- a/examples/content-shadow-dom/template.spec.ts +++ /dev/null @@ -1,70 +0,0 @@ -import path from 'path' -import {execSync} from 'child_process' -import {extensionFixtures} from '../extension-fixtures' - -const exampleDir = 'examples/content-shadow-dom' -const pathToExtension = path.join(__dirname, `dist/chrome`) -const test = extensionFixtures(pathToExtension, true) - -test.beforeAll(async () => { - execSync(`pnpm extension build ${exampleDir}`, { - cwd: path.join(__dirname, '..') - }) -}) - -test('should exist an element with the class name extension-root', async ({ - page -}) => { - await page.goto('https://extension.js.org/') - const div = page.locator('#extension-root') - await test.expect(div).toBeVisible() -}) - -test('should exist an h2 element with specified content', async ({page}) => { - await page.goto('https://extension.js.org/') - const h2 = page.locator('#extension-root h2') - await test - .expect(h2) - .toHaveText('This is a content script running Tailwind.css.') -}) - -test('should exist a default color value', async ({page}) => { - await page.goto('https://extension.js.org/') - const h2 = page.locator('#extension-root h2') - const color = await page.evaluate( - (locator) => { - return window.getComputedStyle(locator!).getPropertyValue('color') - }, - await h2.elementHandle() - ) - await test.expect(color).toEqual('rgb(255, 255, 255)') -}) - -test('should load all images successfully', async ({page}) => { - await page.goto('https://extension.js.org/') - const images = page.locator('#extension-root img') - const imageElements = await images.all() - - const results: boolean[] = [] - - for (const image of imageElements) { - const naturalWidth = await page.evaluate( - (img) => { - return img ? (img as HTMLImageElement).naturalWidth : 0 - }, - await image.elementHandle() - ) - - const naturalHeight = await page.evaluate( - (img) => { - return img ? (img as HTMLImageElement).naturalHeight : 0 - }, - await image.elementHandle() - ) - - const loadedSuccessfully = naturalWidth > 0 && naturalHeight > 0 - results.push(loadedSuccessfully) - } - - await test.expect(results.every((result) => result)).toBeTruthy() -}) diff --git a/examples/content-tailwind/background.js b/examples/content-tailwind/background.js index bfd9ec37..798d5018 100644 --- a/examples/content-tailwind/background.js +++ b/examples/content-tailwind/background.js @@ -1,21 +1 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} +console.log('Hello from the background script!') diff --git a/examples/content-tailwind/manifest.json b/examples/content-tailwind/manifest.json index a415ab3b..0ac8f47f 100644 --- a/examples/content-tailwind/manifest.json +++ b/examples/content-tailwind/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts Tailwind Template", + "name": "Content Scripts Tailwind", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-tailwind/template.spec.ts b/examples/content-tailwind/template.spec.ts index e3b0ca27..2ecac76c 100644 --- a/examples/content-tailwind/template.spec.ts +++ b/examples/content-tailwind/template.spec.ts @@ -25,7 +25,7 @@ test('should exist an h2 element with specified content', async ({page}) => { const h2 = page.locator('#extension-root h2') await test .expect(h2) - .toHaveText('This is a content script running Tailwind.css.') + .toContainText('This is a content script running Tailwind.css.') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/content-typescript/background.ts b/examples/content-typescript/background.ts index 3f38062b..bcc3c653 100644 --- a/examples/content-typescript/background.ts +++ b/examples/content-typescript/background.ts @@ -1,26 +1 @@ -console.log('hello from background script') - -// eslint-disable-next-line no-undef -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - handleChangeBackgroundColor(request.color, sender.tab?.id) - } -}) - -function handleChangeBackgroundColor(color: string, tabId: number | undefined) { - if (!tabId) { - return - } - - chrome.scripting - .executeScript({ - target: {tabId}, - func: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color: string) { - document.body.style.backgroundColor = color -} +console.log('Hello from the background!') diff --git a/examples/content-typescript/content/scripts.ts b/examples/content-typescript/content/scripts.ts index 6e92e5ab..139825c3 100644 --- a/examples/content-typescript/content/scripts.ts +++ b/examples/content-typescript/content/scripts.ts @@ -1,15 +1,15 @@ import './styles.css' +import logo from '../images/logo.svg' console.log('hello from content_scripts') document.body.innerHTML += ` -
- -

- Change the background-color ⬇ + ` - -document.getElementById('colorPicker')?.addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - // @ts-expect-error - color: event.target?.value - }) - .catch(console.error) -}) diff --git a/examples/content-typescript/content/styles.css b/examples/content-typescript/content/styles.css index 092f3152..2049a65c 100644 --- a/examples/content-typescript/content/styles.css +++ b/examples/content-typescript/content/styles.css @@ -1,45 +1,37 @@ -.content_script-box { - background: white; +.content_script { + color: #c9c9c9; + background-color: #0a0c10; position: fixed; right: 0; bottom: 0; z-index: 9; width: 315px; - height: 345px; - margin: 1em; - padding: 1em; + margin: 1rem; + padding: 2rem 1rem; display: flex; - align-items: center; - justify-content: center; flex-direction: column; gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; + border-radius: 6px; } -.content_script-logo { - width: 90px; - align-self: flex-start; +.content_logo { + width: 72px; } -.content_script-title { +.content_title { font-size: 1.85em; - color: #333; line-height: 1.1; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; } -.content_script-description { - color: #999; +.content_description { + font-size: small; } -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; } diff --git a/examples/content-typescript/images/logo.svg b/examples/content-typescript/images/logo.svg new file mode 100644 index 00000000..7fe14ba4 --- /dev/null +++ b/examples/content-typescript/images/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/content-typescript/manifest.json b/examples/content-typescript/manifest.json index 6a81adc8..f0d062dc 100644 --- a/examples/content-typescript/manifest.json +++ b/examples/content-typescript/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts TypeScript Template", + "name": "Content Scripts Typescript", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-typescript/public/logo.svg b/examples/content-typescript/public/logo.svg new file mode 100644 index 00000000..7fe14ba4 --- /dev/null +++ b/examples/content-typescript/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/content-typescript/template.spec.ts b/examples/content-typescript/template.spec.ts index b91cb570..477a9668 100644 --- a/examples/content-typescript/template.spec.ts +++ b/examples/content-typescript/template.spec.ts @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/content-vue/content/ContentApp.vue b/examples/content-vue/content/ContentApp.vue index 9a768125..e99f663c 100644 --- a/examples/content-vue/content/ContentApp.vue +++ b/examples/content-vue/content/ContentApp.vue @@ -32,7 +32,7 @@ const setIsDialogOpen = (value: boolean) => (isdialogOpen.value = value) > Vue logo
+
diff --git a/examples/content-vue/public/vue.svg b/examples/content-vue/images/logo.svg similarity index 100% rename from examples/content-vue/public/vue.svg rename to examples/content-vue/images/logo.svg diff --git a/examples/content-vue/manifest.json b/examples/content-vue/manifest.json index aec108a7..2f01063e 100644 --- a/examples/content-vue/manifest.json +++ b/examples/content-vue/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts Vue Template", + "name": "Content Scripts Vue", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content-vue/public/logo.svg b/examples/content-vue/public/logo.svg new file mode 100644 index 00000000..d4d5f0bd --- /dev/null +++ b/examples/content-vue/public/logo.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/examples/content-vue/template.spec.ts b/examples/content-vue/template.spec.ts index 5ddd38a5..a9bc8590 100644 --- a/examples/content-vue/template.spec.ts +++ b/examples/content-vue/template.spec.ts @@ -25,7 +25,7 @@ test('should exist an h2 element with specified content', async ({page}) => { const h2 = page.locator('#extension-root h2') await test .expect(h2) - .toHaveText( + .toContainText( 'This is a content script running Vue, TypeScript, and Tailwind.css.' ) }) diff --git a/examples/content/background.js b/examples/content/background.js index bfd9ec37..798d5018 100644 --- a/examples/content/background.js +++ b/examples/content/background.js @@ -1,21 +1 @@ -console.log('hello from background script') - -chrome.runtime.onMessage.addListener((request, sender) => { - if (request.action === 'changeBackgroundColor') { - changeBackgroundColor(request.color, sender.tab.id) - } -}) - -function changeBackgroundColor(color, tabId) { - chrome.scripting - .executeScript({ - target: {tabId}, - function: setPageBackgroundColor, - args: [color] - }) - .catch(console.error) -} - -function setPageBackgroundColor(color) { - document.body.style.backgroundColor = color -} +console.log('Hello from the background script!') diff --git a/examples/content/content/scripts.js b/examples/content/content/scripts.js index 1f455709..d010d8ab 100644 --- a/examples/content/content/scripts.js +++ b/examples/content/content/scripts.js @@ -1,15 +1,16 @@ import './styles.css' +import logo from '../images/logo.svg' console.log('hello from content_scripts') +// Check if the content has already been added document.body.innerHTML += ` -
- -

- Change the background-color ⬇ + -` - -document.getElementById('colorPicker').addEventListener('input', (event) => { - chrome.runtime - .sendMessage({ - action: 'changeBackgroundColor', - color: event.target.value - }) - .catch(console.error) -}) + ` diff --git a/examples/content/content/styles.css b/examples/content/content/styles.css index 3e90a639..2049a65c 100644 --- a/examples/content/content/styles.css +++ b/examples/content/content/styles.css @@ -1,54 +1,37 @@ -.content_script-box { - background: white; +.content_script { + color: #c9c9c9; + background-color: #0a0c10; position: fixed; right: 0; bottom: 0; z-index: 9; width: 315px; - height: 345px; - margin: 1em; - padding: 1em; + margin: 1rem; + padding: 2rem 1rem; display: flex; - align-items: center; - justify-content: center; flex-direction: column; gap: 1em; - box-shadow: 0px 0px 4px 1px #ccc; + border-radius: 6px; } -.content_script-logo { - width: 90px; - align-self: flex-start; - filter: grayscale(1); - transition: - filter 2s, - border-color 2s; +.content_logo { + width: 72px; } -.content_script-logo:hover { - filter: grayscale(0); - border-color: aquamarine; -} - -.content_script-title { +.content_title { font-size: 1.85em; - color: #333; line-height: 1.1; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; font-weight: 700; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; } -.content_script-description { - color: #999; +.content_description { + font-size: small; } -.content_script-colorPicker { - display: block; - width: 100%; - height: 50px; +.content_description a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; } diff --git a/examples/config-stylelint/public/logo.svg b/examples/content/images/logo.svg similarity index 100% rename from examples/config-stylelint/public/logo.svg rename to examples/content/images/logo.svg diff --git a/examples/content/manifest.json b/examples/content/manifest.json index 503d2eba..161123ce 100644 --- a/examples/content/manifest.json +++ b/examples/content/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Content Scripts Template", + "name": "Content Script", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/content/public/logo.svg b/examples/content/public/logo.svg deleted file mode 100644 index ebe0773a..00000000 --- a/examples/content/public/logo.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/content/template.spec.ts b/examples/content/template.spec.ts index 164a642d..e1a41236 100644 --- a/examples/content/template.spec.ts +++ b/examples/content/template.spec.ts @@ -12,28 +12,28 @@ test.beforeAll(async () => { }) }) -test('should exist an element with the class name content_script-box', async ({ +test('should exist an element with the class name content_script', async ({ page }) => { await page.goto('https://extension.js.org/') - const div = page.locator('body > div.content_script-box') + const div = page.locator('body > div.content_script') await test.expect(div).toBeVisible() }) test('should exist an h1 element with specified content', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') - await test.expect(h1).toHaveText('Change the background-color ⬇') + const h1 = page.locator('body > div.content_script > h1') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { await page.goto('https://extension.js.org/') - const h1 = page.locator('body > div.content_script-box > h1') + const h1 = page.locator('body > div.content_script > h1') const color = await page.evaluate( (locator) => { return window.getComputedStyle(locator!).getPropertyValue('color') }, await h1.elementHandle() ) - await test.expect(color).toEqual('rgb(51, 51, 51)') + await test.expect(color).toEqual('rgb(201, 201, 201)') }) diff --git a/examples/data.ts b/examples/data.ts index 4d3047b3..6cb58584 100644 --- a/examples/data.ts +++ b/examples/data.ts @@ -39,7 +39,7 @@ const JS_TEMPLATES: Template[] = [ configFiles: undefined }, { - name: 'content-css-module', + name: 'content-css-modules', uiContext: ['content'], uiFramework: undefined, css: 'css', @@ -57,7 +57,7 @@ const JS_TEMPLATES: Template[] = [ configFiles: undefined }, { - name: 'content-less-module', + name: 'content-less-modules', uiContext: ['content'], uiFramework: undefined, css: 'less', @@ -84,7 +84,7 @@ const JS_TEMPLATES: Template[] = [ configFiles: undefined }, { - name: 'content-sass-module', + name: 'content-sass-modules', uiContext: ['content'], uiFramework: undefined, css: 'sass', @@ -111,7 +111,7 @@ const JS_TEMPLATES: Template[] = [ configFiles: undefined }, { - name: 'locales', + name: 'action-locales', uiContext: ['action'], uiFramework: undefined, css: 'css', @@ -253,6 +253,15 @@ const CUSTOM_TEMPLATES: Template[] = [ hasEnv: false, configFiles: ['tsconfig.json', 'extension.config.js'] }, + { + name: 'new-node-apis', + uiContext: ['newTab'], + uiFramework: undefined, + css: 'css', + hasBackground: false, + hasEnv: false, + configFiles: ['tsconfig.json', 'extension.config.js'] + }, { name: 'content-react-svgr', uiContext: ['content'], @@ -360,7 +369,7 @@ const CONFIG_TEMPLATES: Template[] = [ // configFiles: ['babel.config.json'] // }, { - name: 'config-eslint', + name: 'new-config-eslint', uiContext: ['newTab'], uiFramework: undefined, css: 'css', @@ -369,7 +378,7 @@ const CONFIG_TEMPLATES: Template[] = [ configFiles: ['tsconfig.json', 'eslint.config.mjs'] }, { - name: 'config-lint', + name: 'new-config-lint', uiContext: ['newTab'], uiFramework: undefined, css: 'css', @@ -384,7 +393,7 @@ const CONFIG_TEMPLATES: Template[] = [ ] }, { - name: 'config-prettier', + name: 'new-config-prettier', uiContext: ['newTab'], uiFramework: undefined, css: 'css', @@ -393,7 +402,7 @@ const CONFIG_TEMPLATES: Template[] = [ configFiles: ['tsconfig.json', '.prettierrc'] }, { - name: 'config-stylelint', + name: 'new-config-stylelint', uiContext: ['newTab'], uiFramework: undefined, css: 'sass', diff --git a/examples/declarative_net_request/manifest.json b/examples/declarative_net_request/manifest.json index a2a374ed..157e471d 100644 --- a/examples/declarative_net_request/manifest.json +++ b/examples/declarative_net_request/manifest.json @@ -1,5 +1,5 @@ { - "name": "Declarative Net Request Template", + "name": "Declarative_net_request", "version": "0.0.1", "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, diff --git a/examples/init/manifest.json b/examples/init/manifest.json index 8f4be86f..10a19048 100644 --- a/examples/init/manifest.json +++ b/examples/init/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Init Template", + "name": "Init", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/locales/action/scripts.js b/examples/locales/action/scripts.js deleted file mode 100644 index 573ffae1..00000000 --- a/examples/locales/action/scripts.js +++ /dev/null @@ -1,3 +0,0 @@ -document.getElementById('title').textContent = chrome.i18n.getMessage('title') -document.getElementById('learnMore').textContent = - chrome.i18n.getMessage('learnMore') diff --git a/examples/locales/action/styles.css b/examples/locales/action/styles.css deleted file mode 100644 index 69a24316..00000000 --- a/examples/locales/action/styles.css +++ /dev/null @@ -1,87 +0,0 @@ -html { - font-size: 62.5%; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; -} - -body { - display: flex; - justify-content: center; - align-items: center; - height: calc(100vh - 4rem); - min-width: 300px; - padding: 2rem; - font-size: 1.8rem; - line-height: 1.618; - max-width: 38em; - margin: auto; - color: #c9c9c9; - background-color: #0A0C10; -} - -@media (max-width: 684px) { - body { - font-size: 1.53rem; - } -} - -@media (max-width: 382px) { - body { - font-size: 1.35rem; - } -} - -h1 { - line-height: 1.1; - font-weight: 700; - margin-bottom: 1.5rem; - overflow-wrap: break-word; - word-wrap: break-word; - -ms-word-break: break-all; - word-break: break-word; - font-size: 4.7em; -} - -@media (max-width: 684px) { - h1 { - font-size: 2.7em; - } -} - -p { - margin-top: 0px; - margin-bottom: 2.5rem; -} - -a { - text-decoration: none; - border-bottom: 2px solid #c9c9c9; - color: #e5e7eb; -} - - -img { - height: auto; - max-width: 100%; - margin-top: 0px; - margin-bottom: 2.5rem; -} - -@media (max-width: 684px) { - img { - margin-top: 2rem; - margin-bottom: 1rem; - } -} - -body { - display: flex; - justify-content: center; - align-items: center; - height: calc(100vh - 4rem); -} - -header > div { - display: flex; - align-items: center; -} \ No newline at end of file diff --git a/examples/locales/public/extension.svg b/examples/locales/public/extension.svg deleted file mode 100644 index ebe0773a..00000000 --- a/examples/locales/public/extension.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/config-stylelint/.gitignore b/examples/new-config-babel/.gitignore similarity index 100% rename from examples/config-stylelint/.gitignore rename to examples/new-config-babel/.gitignore diff --git a/examples/config-babel/babel.config.json b/examples/new-config-babel/babel.config.json similarity index 100% rename from examples/config-babel/babel.config.json rename to examples/new-config-babel/babel.config.json diff --git a/examples/config-babel/extension.config.js b/examples/new-config-babel/extension.config.js similarity index 100% rename from examples/config-babel/extension.config.js rename to examples/new-config-babel/extension.config.js diff --git a/examples/config-stylelint/images/extension_48.png b/examples/new-config-babel/images/extension_48.png similarity index 100% rename from examples/config-stylelint/images/extension_48.png rename to examples/new-config-babel/images/extension_48.png diff --git a/examples/config-stylelint/manifest.json b/examples/new-config-babel/manifest.json similarity index 89% rename from examples/config-stylelint/manifest.json rename to examples/new-config-babel/manifest.json index a152e526..9addd8b4 100644 --- a/examples/config-stylelint/manifest.json +++ b/examples/new-config-babel/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Stylelint Template", + "name": "New Tab Config Babel", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/config-babel/newtab/index.html b/examples/new-config-babel/newtab/index.html similarity index 100% rename from examples/config-babel/newtab/index.html rename to examples/new-config-babel/newtab/index.html diff --git a/examples/new-config-babel/newtab/scripts.js b/examples/new-config-babel/newtab/scripts.js new file mode 100644 index 00000000..7fcefeb3 --- /dev/null +++ b/examples/new-config-babel/newtab/scripts.js @@ -0,0 +1 @@ +console.log('Hello from the new tab page!') diff --git a/examples/config-babel/newtab/styles.css b/examples/new-config-babel/newtab/styles.css similarity index 100% rename from examples/config-babel/newtab/styles.css rename to examples/new-config-babel/newtab/styles.css diff --git a/examples/config-babel/package.json b/examples/new-config-babel/package.json similarity index 92% rename from examples/config-babel/package.json rename to examples/new-config-babel/package.json index 52bc7389..fa0d6b6a 100644 --- a/examples/config-babel/package.json +++ b/examples/new-config-babel/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "config-babel", + "name": "new-config-babel", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/config-babel/public/logo.png b/examples/new-config-babel/public/logo.png similarity index 100% rename from examples/config-babel/public/logo.png rename to examples/new-config-babel/public/logo.png diff --git a/examples/content-css-module/.gitignore b/examples/new-config-eslint/.gitignore similarity index 100% rename from examples/content-css-module/.gitignore rename to examples/new-config-eslint/.gitignore diff --git a/examples/config-eslint/eslint.config.mjs b/examples/new-config-eslint/eslint.config.mjs similarity index 100% rename from examples/config-eslint/eslint.config.mjs rename to examples/new-config-eslint/eslint.config.mjs diff --git a/examples/content-css-module/images/extension_48.png b/examples/new-config-eslint/images/extension_48.png similarity index 100% rename from examples/content-css-module/images/extension_48.png rename to examples/new-config-eslint/images/extension_48.png diff --git a/examples/config-eslint/manifest.json b/examples/new-config-eslint/manifest.json similarity index 88% rename from examples/config-eslint/manifest.json rename to examples/new-config-eslint/manifest.json index 25304669..1bac6e20 100644 --- a/examples/config-eslint/manifest.json +++ b/examples/new-config-eslint/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "ESLint Template", + "name": "New Tab Config Eslint", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/config-eslint/newtab/index.html b/examples/new-config-eslint/newtab/index.html similarity index 100% rename from examples/config-eslint/newtab/index.html rename to examples/new-config-eslint/newtab/index.html diff --git a/examples/config-eslint/newtab/scripts.ts b/examples/new-config-eslint/newtab/scripts.ts similarity index 100% rename from examples/config-eslint/newtab/scripts.ts rename to examples/new-config-eslint/newtab/scripts.ts diff --git a/examples/config-eslint/newtab/styles.css b/examples/new-config-eslint/newtab/styles.css similarity index 100% rename from examples/config-eslint/newtab/styles.css rename to examples/new-config-eslint/newtab/styles.css diff --git a/examples/config-eslint/package.json b/examples/new-config-eslint/package.json similarity index 93% rename from examples/config-eslint/package.json rename to examples/new-config-eslint/package.json index ed38f1a3..4dd04adc 100644 --- a/examples/config-eslint/package.json +++ b/examples/new-config-eslint/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "config-eslint", + "name": "new-config-eslint", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/config-eslint/public/logo.svg b/examples/new-config-eslint/public/logo.svg similarity index 100% rename from examples/config-eslint/public/logo.svg rename to examples/new-config-eslint/public/logo.svg diff --git a/examples/config-eslint/tsconfig.json b/examples/new-config-eslint/tsconfig.json similarity index 100% rename from examples/config-eslint/tsconfig.json rename to examples/new-config-eslint/tsconfig.json diff --git a/examples/content-less-module/.gitignore b/examples/new-config-lint/.gitignore similarity index 100% rename from examples/content-less-module/.gitignore rename to examples/new-config-lint/.gitignore diff --git a/examples/config-lint/.prettierrc b/examples/new-config-lint/.prettierrc similarity index 100% rename from examples/config-lint/.prettierrc rename to examples/new-config-lint/.prettierrc diff --git a/examples/config-lint/.stylelintrc.json b/examples/new-config-lint/.stylelintrc.json similarity index 100% rename from examples/config-lint/.stylelintrc.json rename to examples/new-config-lint/.stylelintrc.json diff --git a/examples/config-lint/eslint.config.mjs b/examples/new-config-lint/eslint.config.mjs similarity index 100% rename from examples/config-lint/eslint.config.mjs rename to examples/new-config-lint/eslint.config.mjs diff --git a/examples/content-less-module/images/extension_48.png b/examples/new-config-lint/images/extension_48.png similarity index 100% rename from examples/content-less-module/images/extension_48.png rename to examples/new-config-lint/images/extension_48.png diff --git a/examples/config-lint/manifest.json b/examples/new-config-lint/manifest.json similarity index 89% rename from examples/config-lint/manifest.json rename to examples/new-config-lint/manifest.json index e7235ba3..fb1a7768 100644 --- a/examples/config-lint/manifest.json +++ b/examples/new-config-lint/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Lint Template", + "name": "New Tab Config Lint", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/config-lint/newtab/index.html b/examples/new-config-lint/newtab/index.html similarity index 100% rename from examples/config-lint/newtab/index.html rename to examples/new-config-lint/newtab/index.html diff --git a/examples/config-lint/newtab/scripts.ts b/examples/new-config-lint/newtab/scripts.ts similarity index 100% rename from examples/config-lint/newtab/scripts.ts rename to examples/new-config-lint/newtab/scripts.ts diff --git a/examples/config-lint/newtab/styles.css b/examples/new-config-lint/newtab/styles.css similarity index 100% rename from examples/config-lint/newtab/styles.css rename to examples/new-config-lint/newtab/styles.css diff --git a/examples/config-lint/package.json b/examples/new-config-lint/package.json similarity index 95% rename from examples/config-lint/package.json rename to examples/new-config-lint/package.json index aa3b861f..bb7d0107 100644 --- a/examples/config-lint/package.json +++ b/examples/new-config-lint/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "config-lint", + "name": "new-config-lint", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/content-css-module/public/logo.svg b/examples/new-config-lint/public/logo.svg similarity index 100% rename from examples/content-css-module/public/logo.svg rename to examples/new-config-lint/public/logo.svg diff --git a/examples/config-lint/tsconfig.json b/examples/new-config-lint/tsconfig.json similarity index 100% rename from examples/config-lint/tsconfig.json rename to examples/new-config-lint/tsconfig.json diff --git a/examples/content-sass-module/.gitignore b/examples/new-config-prettier/.gitignore similarity index 100% rename from examples/content-sass-module/.gitignore rename to examples/new-config-prettier/.gitignore diff --git a/examples/config-prettier/.prettierrc b/examples/new-config-prettier/.prettierrc similarity index 100% rename from examples/config-prettier/.prettierrc rename to examples/new-config-prettier/.prettierrc diff --git a/examples/content-sass-module/images/extension_48.png b/examples/new-config-prettier/images/extension_48.png similarity index 100% rename from examples/content-sass-module/images/extension_48.png rename to examples/new-config-prettier/images/extension_48.png diff --git a/examples/new-config-prettier/manifest.json b/examples/new-config-prettier/manifest.json new file mode 100644 index 00000000..c37d0de3 --- /dev/null +++ b/examples/new-config-prettier/manifest.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://json.schemastore.org/chrome-manifest.json", + "manifest_version": 3, + "version": "0.0.1", + "name": "New Tab Config Prettier", + "description": "An Extension.js example.", + "icons": { + "48": "images/extension_48.png" + }, + "chrome_url_overrides": { + "newtab": "newtab/index.html" + } +} diff --git a/examples/config-prettier/newtab/index.html b/examples/new-config-prettier/newtab/index.html similarity index 100% rename from examples/config-prettier/newtab/index.html rename to examples/new-config-prettier/newtab/index.html diff --git a/examples/config-prettier/newtab/scripts.ts b/examples/new-config-prettier/newtab/scripts.ts similarity index 100% rename from examples/config-prettier/newtab/scripts.ts rename to examples/new-config-prettier/newtab/scripts.ts diff --git a/examples/config-prettier/newtab/styles.css b/examples/new-config-prettier/newtab/styles.css similarity index 100% rename from examples/config-prettier/newtab/styles.css rename to examples/new-config-prettier/newtab/styles.css diff --git a/examples/config-prettier/package.json b/examples/new-config-prettier/package.json similarity index 91% rename from examples/config-prettier/package.json rename to examples/new-config-prettier/package.json index 871a1d73..855f199c 100644 --- a/examples/config-prettier/package.json +++ b/examples/new-config-prettier/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "config-prettier", + "name": "new-config-prettier", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/config-prettier/public/logo.svg b/examples/new-config-prettier/public/logo.svg similarity index 100% rename from examples/config-prettier/public/logo.svg rename to examples/new-config-prettier/public/logo.svg diff --git a/examples/config-prettier/tsconfig.json b/examples/new-config-prettier/tsconfig.json similarity index 100% rename from examples/config-prettier/tsconfig.json rename to examples/new-config-prettier/tsconfig.json diff --git a/examples/content-shadow-dom/.gitignore b/examples/new-config-stylelint/.gitignore similarity index 100% rename from examples/content-shadow-dom/.gitignore rename to examples/new-config-stylelint/.gitignore diff --git a/examples/config-stylelint/.stylelintrc.json b/examples/new-config-stylelint/.stylelintrc.json similarity index 100% rename from examples/config-stylelint/.stylelintrc.json rename to examples/new-config-stylelint/.stylelintrc.json diff --git a/examples/content-shadow-dom/images/extension_48.png b/examples/new-config-stylelint/images/extension_48.png similarity index 100% rename from examples/content-shadow-dom/images/extension_48.png rename to examples/new-config-stylelint/images/extension_48.png diff --git a/examples/config-prettier/manifest.json b/examples/new-config-stylelint/manifest.json similarity index 88% rename from examples/config-prettier/manifest.json rename to examples/new-config-stylelint/manifest.json index 6a1a3796..7e25a60b 100644 --- a/examples/config-prettier/manifest.json +++ b/examples/new-config-stylelint/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Config Prettier Template", + "name": "New Tab Config Stylelint", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/config-stylelint/newtab/index.html b/examples/new-config-stylelint/newtab/index.html similarity index 100% rename from examples/config-stylelint/newtab/index.html rename to examples/new-config-stylelint/newtab/index.html diff --git a/examples/new-config-stylelint/newtab/scripts.js b/examples/new-config-stylelint/newtab/scripts.js new file mode 100644 index 00000000..7fcefeb3 --- /dev/null +++ b/examples/new-config-stylelint/newtab/scripts.js @@ -0,0 +1 @@ +console.log('Hello from the new tab page!') diff --git a/examples/config-stylelint/newtab/styles.scss b/examples/new-config-stylelint/newtab/styles.scss similarity index 100% rename from examples/config-stylelint/newtab/styles.scss rename to examples/new-config-stylelint/newtab/styles.scss diff --git a/examples/config-stylelint/package.json b/examples/new-config-stylelint/package.json similarity index 92% rename from examples/config-stylelint/package.json rename to examples/new-config-stylelint/package.json index 67e4e045..0844f520 100644 --- a/examples/config-stylelint/package.json +++ b/examples/new-config-stylelint/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "config-stylelint", + "name": "new-config-stylelint", "description": "An Extension.js example.", "version": "0.0.1", "author": { diff --git a/examples/content-less-module/public/logo.svg b/examples/new-config-stylelint/public/logo.svg similarity index 100% rename from examples/content-less-module/public/logo.svg rename to examples/new-config-stylelint/public/logo.svg diff --git a/examples/new-crypto/manifest.json b/examples/new-crypto/manifest.json index ffffb0e2..56ed29fd 100644 --- a/examples/new-crypto/manifest.json +++ b/examples/new-crypto/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab Crypto Template", + "name": "New Tab Crypto", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-crypto/newtab/styles.css b/examples/new-crypto/newtab/styles.css index 3de01a9d..51affe2c 100644 --- a/examples/new-crypto/newtab/styles.css +++ b/examples/new-crypto/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-crypto/template.spec.ts b/examples/new-crypto/template.spec.ts index 9b66fd5d..13549fde 100644 --- a/examples/new-crypto/template.spec.ts +++ b/examples/new-crypto/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your Crypto Extension.') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-env-esm/manifest.json b/examples/new-env-esm/manifest.json index 652f8e2d..10f32347 100644 --- a/examples/new-env-esm/manifest.json +++ b/examples/new-env-esm/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab ESM + .env Template", + "name": "New Tab Env Esm", "description": "$EXTENSION_PUBLIC_DESCRIPTION_TEXT", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-env-esm/newtab/index.html b/examples/new-env-esm/newtab/index.html index e877c4bf..b25c83d9 100644 --- a/examples/new-env-esm/newtab/index.html +++ b/examples/new-env-esm/newtab/index.html @@ -3,7 +3,7 @@ - New ESModule + .env Extension + .env ESModule Extension @@ -16,7 +16,7 @@

width="120px" />
- Welcome to your New ESModule + .env Extension + Welcome to your .env ESModule Extension

Learn more about creating cross-browser extensions at diff --git a/examples/new-env-esm/newtab/scripts.mjs b/examples/new-env-esm/newtab/scripts.mjs index 29d939dc..7fcefeb3 100644 --- a/examples/new-env-esm/newtab/scripts.mjs +++ b/examples/new-env-esm/newtab/scripts.mjs @@ -1,11 +1 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: import.meta.env.EXTENSION_PUBLIC_DESCRIPTION_TEXT -}) +console.log('Hello from the new tab page!') diff --git a/examples/new-env-esm/newtab/styles.css b/examples/new-env-esm/newtab/styles.css index 0fb72398..7d8a01f2 100644 --- a/examples/new-env-esm/newtab/styles.css +++ b/examples/new-env-esm/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-env-esm/template.spec.mjs b/examples/new-env-esm/template.spec.mjs index 2620ce5a..eec6bb0b 100644 --- a/examples/new-env-esm/template.spec.mjs +++ b/examples/new-env-esm/template.spec.mjs @@ -23,9 +23,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test - .expect(h1) - .toHaveText('Welcome to your New ESModule + .env Extension') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-env/manifest.json b/examples/new-env/manifest.json index 8d8fba76..f622fae2 100644 --- a/examples/new-env/manifest.json +++ b/examples/new-env/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab .env Template", + "name": "New Tab Env", "description": "$EXTENSION_PUBLIC_DESCRIPTION_TEXT", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-env/newtab/scripts.ts b/examples/new-env/newtab/scripts.ts index 94404b12..7fcefeb3 100644 --- a/examples/new-env/newtab/scripts.ts +++ b/examples/new-env/newtab/scripts.ts @@ -1,10 +1 @@ -function getManifestData() { - return chrome.runtime.getManifest() -} -const extensionManifest = getManifestData() - -console.table({ - name: extensionManifest.name, - version: extensionManifest.version, - description: process.env.EXTENSION_PUBLIC_DESCRIPTION_TEXT -}) +console.log('Hello from the new tab page!') diff --git a/examples/new-env/newtab/styles.css b/examples/new-env/newtab/styles.css index f888963c..da24ea2a 100644 --- a/examples/new-env/newtab/styles.css +++ b/examples/new-env/newtab/styles.css @@ -16,7 +16,7 @@ body { max-width: 38em; margin: auto; color: #c9c9c9; - background-color: #0A0C10; + background-color: #0a0c10; } @media (max-width: 684px) { @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.5em; } @@ -59,7 +58,6 @@ a { color: #e5e7eb; } - img { height: auto; max-width: 100%; @@ -81,7 +79,7 @@ body { height: calc(100vh - 4rem); } -header>div { +header > div { display: flex; align-items: center; -} \ No newline at end of file +} diff --git a/examples/new-env/template.spec.ts b/examples/new-env/template.spec.ts index 8b03a3f5..b58e0dea 100644 --- a/examples/new-env/template.spec.ts +++ b/examples/new-env/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your Chrome Extension.') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-esm/manifest.json b/examples/new-esm/manifest.json index 4895f213..564d2b26 100644 --- a/examples/new-esm/manifest.json +++ b/examples/new-esm/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab ESM Template", + "name": "New Tab Esm", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-esm/newtab/index.html b/examples/new-esm/newtab/index.html index 042f2fd9..584a7551 100644 --- a/examples/new-esm/newtab/index.html +++ b/examples/new-esm/newtab/index.html @@ -16,7 +16,7 @@

width="120px" />
- Welcome to your New ESModule Extension + Welcome to your ESModule Extension

Learn more about creating cross-browser extensions at diff --git a/examples/new-esm/newtab/scripts.mjs b/examples/new-esm/newtab/scripts.mjs index 7f6946b3..7fcefeb3 100644 --- a/examples/new-esm/newtab/scripts.mjs +++ b/examples/new-esm/newtab/scripts.mjs @@ -1,11 +1 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) +console.log('Hello from the new tab page!') diff --git a/examples/new-esm/newtab/styles.css b/examples/new-esm/newtab/styles.css index 0fb72398..7d8a01f2 100644 --- a/examples/new-esm/newtab/styles.css +++ b/examples/new-esm/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-esm/template.spec.mjs b/examples/new-esm/template.spec.mjs index 2ed345d5..7a512258 100644 --- a/examples/new-esm/template.spec.mjs +++ b/examples/new-esm/template.spec.mjs @@ -23,7 +23,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your New ESModule Extension') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-less/manifest.json b/examples/new-less/manifest.json index 25c98aed..3fe56811 100644 --- a/examples/new-less/manifest.json +++ b/examples/new-less/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab Less Template", + "name": "New Tab Less", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-less/newtab/scripts.js b/examples/new-less/newtab/scripts.js index 7f6946b3..7fcefeb3 100644 --- a/examples/new-less/newtab/scripts.js +++ b/examples/new-less/newtab/scripts.js @@ -1,11 +1 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) +console.log('Hello from the new tab page!') diff --git a/examples/new-less/newtab/styles.less b/examples/new-less/newtab/styles.less index 0fb72398..7d8a01f2 100644 --- a/examples/new-less/newtab/styles.less +++ b/examples/new-less/newtab/styles.less @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-less/template.spec.ts b/examples/new-less/template.spec.ts index 2108e414..78235cca 100644 --- a/examples/new-less/template.spec.ts +++ b/examples/new-less/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your LESS Extension') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/locales/.gitignore b/examples/new-node-apis/.gitignore similarity index 100% rename from examples/locales/.gitignore rename to examples/new-node-apis/.gitignore diff --git a/examples/new-node-apis/extension.config.js b/examples/new-node-apis/extension.config.js new file mode 100644 index 00000000..31eaea22 --- /dev/null +++ b/examples/new-node-apis/extension.config.js @@ -0,0 +1,15 @@ +const NodePolyfillPlugin = require('node-polyfill-webpack-plugin') + +/** @type {import('extension').FileConfig} */ +module.exports = { + config: (config) => { + config.plugins = [ + ...config.plugins, + new NodePolyfillPlugin({ + additionalAliases: ['process'] + }) + ] + + return config + } +} diff --git a/examples/locales/images/extension_48.png b/examples/new-node-apis/images/extension_48.png similarity index 100% rename from examples/locales/images/extension_48.png rename to examples/new-node-apis/images/extension_48.png diff --git a/examples/content-typescript/public/logo.png b/examples/new-node-apis/images/typescript.png similarity index 100% rename from examples/content-typescript/public/logo.png rename to examples/new-node-apis/images/typescript.png diff --git a/examples/config-babel/manifest.json b/examples/new-node-apis/manifest.json similarity index 90% rename from examples/config-babel/manifest.json rename to examples/new-node-apis/manifest.json index df323698..dbdc2c68 100644 --- a/examples/config-babel/manifest.json +++ b/examples/new-node-apis/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Babel Template", + "name": "New Tab Node Apis", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-node-apis/newtab/index.html b/examples/new-node-apis/newtab/index.html new file mode 100644 index 00000000..2b0a6bbe --- /dev/null +++ b/examples/new-node-apis/newtab/index.html @@ -0,0 +1,34 @@ + + + + + + Node APIs + + + +

+

+ The Crypto Template logo +
+ Welcome to your Node APIs Extension. +

+
+ +
+ + +
+ +
Hash a string to see the result
+
+
+
+ + + + + diff --git a/examples/new-node-apis/newtab/scripts.ts b/examples/new-node-apis/newtab/scripts.ts new file mode 100644 index 00000000..a247a528 --- /dev/null +++ b/examples/new-node-apis/newtab/scripts.ts @@ -0,0 +1,17 @@ +import * as crypto from 'crypto' + +function hashString(input: string): string { + // Hash the input using SHA-256 + return crypto.createHash('sha256').update(input).digest('hex') +} + +document.getElementById('hash-button')?.addEventListener('click', () => { + const inputText = (document.getElementById('input-text') as HTMLInputElement) + .value + const hashedOutput = hashString(inputText) + + const outputElement = document.getElementById('hashed-output') + if (outputElement) { + outputElement.textContent = hashedOutput + } +}) diff --git a/examples/new-node-apis/newtab/styles.css b/examples/new-node-apis/newtab/styles.css new file mode 100644 index 00000000..3de01a9d --- /dev/null +++ b/examples/new-node-apis/newtab/styles.css @@ -0,0 +1,178 @@ +html { + font-size: 62.5%; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, + 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; +} + +body { + display: flex; + justify-content: center; + align-items: center; + height: calc(100vh - 4rem); + min-width: 300px; + padding: 2rem; + font-size: 1.8rem; + line-height: 1.618; + max-width: 38em; + margin: auto; + color: #c9c9c9; + background-color: #0a0c10; +} + +@media (max-width: 684px) { + body { + font-size: 1.53rem; + } +} + +@media (max-width: 382px) { + body { + font-size: 1.35rem; + } +} + +h1 { + line-height: 1.1; + font-weight: 700; + margin-bottom: 1.5rem; + overflow-wrap: break-word; + word-wrap: break-word; + -ms-word-break: break-all; + word-break: break-word; + font-size: 4.7em; +} + +@media (max-width: 684px) { + h1 { + font-size: 2.7em; + } +} + +p { + margin-top: 0px; + margin-bottom: 2.5rem; +} + +a { + text-decoration: none; + border-bottom: 2px solid #c9c9c9; + color: #e5e7eb; +} + +img { + height: auto; + max-width: 100%; + margin-top: 0px; + margin-bottom: 2.5rem; +} + +@media (max-width: 684px) { + img { + margin-top: 2rem; + margin-bottom: 1rem; + } +} + +body { + display: flex; + justify-content: center; + align-items: center; + height: calc(100vh - 4rem); +} + +header > div { + display: flex; + align-items: center; +} + +input { + width: calc(100% - 74px); +} + +input, +button { + height: 58px; +} + +/* Pre and Code */ +pre { + background-color: #4a4a4a; + display: block; + padding: 1em; + overflow-x: auto; + margin-top: 0px; + margin-bottom: 2.5rem; + font-size: 0.9em; +} + +code, +kbd, +samp { + font-size: 0.9em; + padding: 0 0.5em; + background-color: #4a4a4a; + white-space: pre-wrap; +} + +pre > code { + padding: 0; + background-color: transparent; + white-space: pre; + font-size: 1em; +} + +input, +textarea { + border: 1px solid #c9c9c9; +} +input:focus, +textarea:focus { + border: 1px solid #ffffff; +} + +button { + display: inline-block; + padding: 5px 10px; + text-align: center; + text-decoration: none; + white-space: nowrap; + background-color: #ffffff; + color: #222222; + border-radius: 1px; + border: 1px solid #ffffff; + cursor: pointer; + box-sizing: border-box; +} + +button:hover { + background-color: #c9c9c9; + color: #222222; + outline: 0; +} + +button:focus-visible { + outline-style: solid; + outline-width: 2px; +} + +input { + color: #c9c9c9; + padding: 6px 10px; + margin-bottom: 10px; + background-color: #4a4a4a; + border: 1px solid #4a4a4a; + border-radius: 4px; + box-shadow: none; + box-sizing: border-box; +} + +input:focus { + border: 1px solid #ffffff; + outline: 0; +} + +label { + display: block; + margin-bottom: 0.5rem; + font-weight: 600; +} diff --git a/examples/content-shadow-dom/package.json b/examples/new-node-apis/package.json similarity index 66% rename from examples/content-shadow-dom/package.json rename to examples/new-node-apis/package.json index 1f6028c8..3cbf5bf9 100644 --- a/examples/content-shadow-dom/package.json +++ b/examples/new-node-apis/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "content-shadow-dom", + "name": "new-node-apis", "description": "An Extension.js example.", "version": "0.0.1", "author": { @@ -9,7 +9,8 @@ "url": "https://cezaraugusto.com" }, "license": "MIT", - "dependencies": { - "tailwindcss": "^3.4.1" + "devDependencies": { + "node-polyfill-webpack-plugin": "^4.0.0", + "typescript": "5.3.3" } } diff --git a/examples/content-sass-module/public/logo.svg b/examples/new-node-apis/public/logo.svg similarity index 100% rename from examples/content-sass-module/public/logo.svg rename to examples/new-node-apis/public/logo.svg diff --git a/examples/new-node-apis/template.spec.ts b/examples/new-node-apis/template.spec.ts new file mode 100644 index 00000000..41626561 --- /dev/null +++ b/examples/new-node-apis/template.spec.ts @@ -0,0 +1,33 @@ +import path from 'path' +import {execSync} from 'child_process' +import {extensionFixtures} from '../extension-fixtures' + +const exampleDir = 'examples/new-node-apis' +const pathToExtension = path.join(__dirname, `dist/chrome`) +const test = extensionFixtures(pathToExtension, true) + +test.beforeAll(async () => { + execSync(`pnpm extension build ${exampleDir}`, { + cwd: path.join(__dirname, '..') + }) +}) + +test('should exist an element with the welcome message text', async ({ + page +}) => { + await page.goto('chrome://newtab/') + const h1 = page.locator('h1') + await test.expect(h1).toContainText('Welcome to your') +}) + +test('should exist a default color value', async ({page}) => { + await page.goto('chrome://newtab/') + const h1 = page.locator('h1') + const color = await page.evaluate( + (locator) => { + return window.getComputedStyle(locator!).getPropertyValue('color') + }, + await h1.elementHandle() + ) + await test.expect(color).toEqual('rgb(201, 201, 201)') +}) diff --git a/examples/new-node-apis/tsconfig.json b/examples/new-node-apis/tsconfig.json new file mode 100644 index 00000000..8f138e5d --- /dev/null +++ b/examples/new-node-apis/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "allowJs": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "isolatedModules": true, + "jsx": "react-jsx", + "lib": ["dom", "dom.iterable", "esnext"], + "moduleResolution": "node", + "module": "esnext", + "noEmit": true, + "resolveJsonModule": true, + "strict": true, + "target": "esnext", + "verbatimModuleSyntax": true, + "useDefineForClassFields": true, + "skipLibCheck": true + }, + "include": ["./"], + "exclude": ["node_modules", "dist"] +} diff --git a/examples/new-preact/manifest.json b/examples/new-preact/manifest.json index 2693f3d6..13f737d0 100644 --- a/examples/new-preact/manifest.json +++ b/examples/new-preact/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab Preact Template", + "name": "New Tab Preact", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-preact/newtab/styles.css b/examples/new-preact/newtab/styles.css index 0fb72398..7d8a01f2 100644 --- a/examples/new-preact/newtab/styles.css +++ b/examples/new-preact/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-preact/template.spec.ts b/examples/new-preact/template.spec.ts index 55a903ba..a7acdc5e 100644 --- a/examples/new-preact/template.spec.ts +++ b/examples/new-preact/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your Preact Extension.') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-react-router/manifest.json b/examples/new-react-router/manifest.json index c48ee3da..2390243d 100644 --- a/examples/new-react-router/manifest.json +++ b/examples/new-react-router/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "New React Router Template", + "name": "New Tab React Router", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-react-router/newtab/styles.css b/examples/new-react-router/newtab/styles.css index d8267dba..c7f23086 100644 --- a/examples/new-react-router/newtab/styles.css +++ b/examples/new-react-router/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-react-router/template.spec.ts b/examples/new-react-router/template.spec.ts index 96b91731..11a3276f 100644 --- a/examples/new-react-router/template.spec.ts +++ b/examples/new-react-router/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your React Router Extension.') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-react/manifest.json b/examples/new-react/manifest.json index 62cc0162..036c92e5 100644 --- a/examples/new-react/manifest.json +++ b/examples/new-react/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "New React Template", + "name": "New Tab React", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-react/newtab/styles.css b/examples/new-react/newtab/styles.css index 0fb72398..7d8a01f2 100644 --- a/examples/new-react/newtab/styles.css +++ b/examples/new-react/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-react/template.spec.ts b/examples/new-react/template.spec.ts index 8d130358..a00d4135 100644 --- a/examples/new-react/template.spec.ts +++ b/examples/new-react/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your React Extension.') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-sass/manifest.json b/examples/new-sass/manifest.json index f58804e8..1a8bcb38 100644 --- a/examples/new-sass/manifest.json +++ b/examples/new-sass/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab SASS Template", + "name": "New Tab Sass", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-sass/newtab/scripts.js b/examples/new-sass/newtab/scripts.js index 7f6946b3..7fcefeb3 100644 --- a/examples/new-sass/newtab/scripts.js +++ b/examples/new-sass/newtab/scripts.js @@ -1,11 +1 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) +console.log('Hello from the new tab page!') diff --git a/examples/new-sass/newtab/styles.scss b/examples/new-sass/newtab/styles.scss index 0fb72398..7d8a01f2 100644 --- a/examples/new-sass/newtab/styles.scss +++ b/examples/new-sass/newtab/styles.scss @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-sass/template.spec.ts b/examples/new-sass/template.spec.ts index 8b638a70..22e7a5d2 100644 --- a/examples/new-sass/template.spec.ts +++ b/examples/new-sass/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your Sass Extension') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-tailwind/manifest.json b/examples/new-tailwind/manifest.json index 661e177a..81c797b2 100644 --- a/examples/new-tailwind/manifest.json +++ b/examples/new-tailwind/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab Tailwind Template", + "name": "New Tab Tailwind", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-tailwind/template.spec.ts b/examples/new-tailwind/template.spec.ts index 4ded3d4b..7c557cb4 100644 --- a/examples/new-tailwind/template.spec.ts +++ b/examples/new-tailwind/template.spec.ts @@ -19,7 +19,7 @@ test('should exist an element with the welcome message text', async ({ const h2 = page.locator('h2') await test .expect(h2) - .toHaveText('This is a new tab page running React and Tailwind.css.') + .toContainText('This is a new tab page running React and Tailwind.css.') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-typescript/manifest.json b/examples/new-typescript/manifest.json index 84d0688b..640ffb06 100644 --- a/examples/new-typescript/manifest.json +++ b/examples/new-typescript/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab TypeScript Template", + "name": "New Tab Typescript", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-typescript/newtab/scripts.ts b/examples/new-typescript/newtab/scripts.ts index f97b0543..7fcefeb3 100644 --- a/examples/new-typescript/newtab/scripts.ts +++ b/examples/new-typescript/newtab/scripts.ts @@ -1,10 +1 @@ -function getRuntimeManifest() { - return chrome.runtime.getManifest() -} -const manifestData = getRuntimeManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) +console.log('Hello from the new tab page!') diff --git a/examples/new-typescript/newtab/styles.css b/examples/new-typescript/newtab/styles.css index 69a24316..75e01d08 100644 --- a/examples/new-typescript/newtab/styles.css +++ b/examples/new-typescript/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-typescript/public/logo.png b/examples/new-typescript/public/logo.png deleted file mode 100644 index 93614694..00000000 Binary files a/examples/new-typescript/public/logo.png and /dev/null differ diff --git a/examples/new-typescript/public/logo.svg b/examples/new-typescript/public/logo.svg new file mode 100644 index 00000000..7fe14ba4 --- /dev/null +++ b/examples/new-typescript/public/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/new-typescript/template.spec.ts b/examples/new-typescript/template.spec.ts index 2ba8c16e..9e590d32 100644 --- a/examples/new-typescript/template.spec.ts +++ b/examples/new-typescript/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your TypeScript Extension.') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new-vue/manifest.json b/examples/new-vue/manifest.json index c6e0d89f..9b9d3fe5 100644 --- a/examples/new-vue/manifest.json +++ b/examples/new-vue/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab Vue Template", + "name": "Newtab Vue", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new-vue/newtab/styles.css b/examples/new-vue/newtab/styles.css index 69a24316..75e01d08 100644 --- a/examples/new-vue/newtab/styles.css +++ b/examples/new-vue/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new-vue/template.spec.ts b/examples/new-vue/template.spec.ts index 115b7dec..c05cad1d 100644 --- a/examples/new-vue/template.spec.ts +++ b/examples/new-vue/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your Vue Extension.') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/new/manifest.json b/examples/new/manifest.json index ffb601e4..cb651390 100644 --- a/examples/new/manifest.json +++ b/examples/new/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, "version": "0.0.1", - "name": "Newtab Template", + "name": "New", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" diff --git a/examples/new/newtab/scripts.js b/examples/new/newtab/scripts.js index 7f6946b3..7fcefeb3 100644 --- a/examples/new/newtab/scripts.js +++ b/examples/new/newtab/scripts.js @@ -1,11 +1 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) +console.log('Hello from the new tab page!') diff --git a/examples/new/newtab/styles.css b/examples/new/newtab/styles.css index 69a24316..75e01d08 100644 --- a/examples/new/newtab/styles.css +++ b/examples/new/newtab/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/new/template.spec.ts b/examples/new/template.spec.ts index d96541e1..7c81fb27 100644 --- a/examples/new/template.spec.ts +++ b/examples/new/template.spec.ts @@ -17,7 +17,7 @@ test('should exist an element with the welcome message text', async ({ }) => { await page.goto('chrome://newtab/') const h1 = page.locator('h1') - await test.expect(h1).toHaveText('Welcome to your New Extension') + await test.expect(h1).toContainText('Welcome to your') }) test('should exist a default color value', async ({page}) => { diff --git a/examples/sidebar/background.js b/examples/sidebar/background.js index a572e5a9..b7680fdc 100644 --- a/examples/sidebar/background.js +++ b/examples/sidebar/background.js @@ -1,6 +1,18 @@ -chrome.action.onClicked.addListener(() => { - chrome.sidePanel.setOptions({ - path: 'side_panel/default_path.html', - enabled: true +if ( + process.env.EXTENSION_PUBLIC_BROWSER === 'firefox' || + process.env.EXTENSION_PUBLIC_BROWSER === 'gecko-based' +) { + // Firefox (Gecko-based browsers) + browser.browserAction.onClicked.addListener(() => { + // Opening the sidebar in Firefox + browser.sidebarAction.open() }) -}) +} else { + // Chromium-based browsers + chrome.action.onClicked.addListener(() => { + chrome.sidePanel.setOptions({ + path: 'side_panel/default_path.html', + enabled: true + }) + }) +} diff --git a/examples/sidebar/manifest.json b/examples/sidebar/manifest.json index cb090c29..5f904643 100644 --- a/examples/sidebar/manifest.json +++ b/examples/sidebar/manifest.json @@ -1,36 +1,30 @@ { "chromium:manifest_version": 3, "firefox:manifest_version": 2, - "version": "0.0.1", - "name": "Sidebar Template", + "name": "Sidebar", "author": "Cezar Augusto", "description": "An Extension.js example.", "icons": { "48": "images/extension_48.png" }, - "chromium:action": { "default_icon": { "48": "images/extension_48.png" }, "default_title": "Open Side Panel" }, - "firefox:sidebar_action": { "default_panel": "sidebar/index.html", "default_title": "Open Sidebar", "default_icon": "images/extension_48.png" }, - "chromium:side_panel": { "default_path": "sidebar/index.html", "default_title": "Side Panel Content" }, - "chromium:permissions": ["sidePanel"], "firefox:permissions": ["storage", "tabs"], - "chromium:web_accessible_resources": [ { "resources": ["sidebar/index.html"], @@ -38,7 +32,6 @@ } ], "firefox:web_accessible_resources": ["sidebar/index.html"], - "background": { "chromium:type": "module", "chromium:service_worker": "background.js", diff --git a/examples/sidebar/sidebar/scripts.js b/examples/sidebar/sidebar/scripts.js index 7f6946b3..4ff9c24a 100644 --- a/examples/sidebar/sidebar/scripts.js +++ b/examples/sidebar/sidebar/scripts.js @@ -1,11 +1 @@ -function getManifest() { - return chrome.runtime.getManifest() -} - -const manifestData = getManifest() - -console.table({ - name: manifestData.name, - version: manifestData.version, - description: manifestData.description -}) +console.log('Hello from the sidebar!') diff --git a/examples/sidebar/sidebar/styles.css b/examples/sidebar/sidebar/styles.css index b1c75834..5342a61a 100644 --- a/examples/sidebar/sidebar/styles.css +++ b/examples/sidebar/sidebar/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/special-folders-pages/manifest.json b/examples/special-folders-pages/manifest.json index b270de1b..c484092a 100644 --- a/examples/special-folders-pages/manifest.json +++ b/examples/special-folders-pages/manifest.json @@ -1,5 +1,5 @@ { - "name": "Special Folders Pages Template", + "name": "Special Folders Pages", "version": "0.0.1", "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, diff --git a/examples/special-folders-pages/sandbox/styles.css b/examples/special-folders-pages/sandbox/styles.css index 247b7733..5292e48a 100644 --- a/examples/special-folders-pages/sandbox/styles.css +++ b/examples/special-folders-pages/sandbox/styles.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/special-folders-scripts/manifest.json b/examples/special-folders-scripts/manifest.json index e4c03bb8..9aeba4ef 100644 --- a/examples/special-folders-scripts/manifest.json +++ b/examples/special-folders-scripts/manifest.json @@ -1,5 +1,5 @@ { - "name": "Special Folders Scripts Template", + "name": "Special Folders Scripts", "version": "0.0.1", "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, diff --git a/examples/special-folders-scripts/pages/index.css b/examples/special-folders-scripts/pages/index.css index 963ccf6f..4e5342f5 100644 --- a/examples/special-folders-scripts/pages/index.css +++ b/examples/special-folders-scripts/pages/index.css @@ -37,7 +37,6 @@ h1 { margin-bottom: 1.5rem; overflow-wrap: break-word; word-wrap: break-word; - -ms-word-break: break-all; word-break: break-word; font-size: 4.7em; } diff --git a/examples/special-folders-scripts/pages/index.js b/examples/special-folders-scripts/pages/index.js index c0f1d436..32ce0f47 100644 --- a/examples/special-folders-scripts/pages/index.js +++ b/examples/special-folders-scripts/pages/index.js @@ -1 +1 @@ -console.log('ok') +console.log('Hello from the index page') diff --git a/examples/special-folders-scripts/scripts/content-script.js b/examples/special-folders-scripts/scripts/content-script.js index 7ead8dc7..ba9d7b16 100644 --- a/examples/special-folders-scripts/scripts/content-script.js +++ b/examples/special-folders-scripts/scripts/content-script.js @@ -1,3 +1,2 @@ -const extensionInfo = chrome.runtime.getManifest() -const text = `${extensionInfo.name} v${extensionInfo.version} injected this script` +const text = `Your browser extension injected this script` alert(text) diff --git a/examples/storage/manifest.json b/examples/storage/manifest.json index 531de6ae..9e01c474 100644 --- a/examples/storage/manifest.json +++ b/examples/storage/manifest.json @@ -1,5 +1,5 @@ { - "name": "Storage Template", + "name": "Storage", "version": "0.0.1", "$schema": "https://json.schemastore.org/chrome-manifest.json", "manifest_version": 3, diff --git a/playwright.config.ts b/playwright.config.ts index 3b4c72b0..3542fd9c 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -11,6 +11,8 @@ import {defineConfig, devices} from '@playwright/test' * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ + // timeout to 40s + timeout: 40 * 1000, testDir: './examples', /* Run tests in files in parallel */ fullyParallel: true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6f73e840..68999c13 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -94,87 +94,11 @@ importers: specifier: 5.3.3 version: 5.3.3 - examples/config-babel: - devDependencies: - '@babel/core': - specifier: ^7.24.9 - version: 7.25.2 - babel-loader: - specifier: ^9.1.3 - version: 9.2.1(@babel/core@7.25.2)(webpack@5.92.1(@swc/core@1.7.26)(esbuild@0.23.1)) - babel-preset-modern-browser-extension: - specifier: ^0.7.0 - version: 0.7.0(@babel/core@7.25.2) - stylelint: - specifier: ^16.7.0 - version: 16.9.0(typescript@5.3.3) - - examples/config-eslint: - devDependencies: - '@eslint/js': - specifier: ^9.6.0 - version: 9.11.0 - eslint: - specifier: ^9.6.0 - version: 9.11.0(jiti@1.21.6) - globals: - specifier: ^15.9.0 - version: 15.9.0 - typescript: - specifier: 5.3.3 - version: 5.3.3 - typescript-eslint: - specifier: ^8.5.0 - version: 8.6.0(eslint@9.11.0(jiti@1.21.6))(typescript@5.3.3) - - examples/config-lint: - devDependencies: - '@eslint/js': - specifier: ^9.6.0 - version: 9.11.0 - eslint: - specifier: ^9.6.0 - version: 9.11.0(jiti@1.21.6) - eslint-config-prettier: - specifier: ^9.1.0 - version: 9.1.0(eslint@9.11.0(jiti@1.21.6)) - globals: - specifier: ^15.9.0 - version: 15.9.0 - prettier: - specifier: ^3.3.2 - version: 3.3.3 - stylelint: - specifier: ^16.7.0 - version: 16.9.0(typescript@5.3.3) - typescript: - specifier: 5.3.3 - version: 5.3.3 - typescript-eslint: - specifier: ^8.5.0 - version: 8.6.0(eslint@9.11.0(jiti@1.21.6))(typescript@5.3.3) - - examples/config-prettier: - devDependencies: - prettier: - specifier: ^3.3.2 - version: 3.3.3 - - examples/config-stylelint: - devDependencies: - sass: - specifier: ^1.77.8 - version: 1.79.2 - stylelint: - specifier: ^16.7.0 - version: 16.9.0(typescript@5.3.3) - stylelint-config-standard-scss: - specifier: ^13.1.0 - version: 13.1.0(postcss@8.4.47)(stylelint@16.9.0(typescript@5.3.3)) + examples/action-locales: {} examples/content: {} - examples/content-css-module: {} + examples/content-css-modules: {} examples/content-env: devDependencies: @@ -212,7 +136,7 @@ importers: specifier: ^4.2.0 version: 4.2.0 - examples/content-less-module: + examples/content-less-modules: devDependencies: less: specifier: ^4.2.0 @@ -298,18 +222,12 @@ importers: specifier: ^1.77.8 version: 1.79.2 - examples/content-sass-module: + examples/content-sass-modules: devDependencies: sass: specifier: ^1.77.8 version: 1.79.2 - examples/content-shadow-dom: - dependencies: - tailwindcss: - specifier: ^3.4.1 - version: 3.4.12(ts-node@10.9.2(@swc/core@1.7.26)(@types/node@22.5.5)(typescript@5.3.3)) - examples/content-tailwind: dependencies: tailwindcss: @@ -339,10 +257,86 @@ importers: examples/init: {} - examples/locales: {} - examples/new: {} + examples/new-config-babel: + devDependencies: + '@babel/core': + specifier: ^7.24.9 + version: 7.25.2 + babel-loader: + specifier: ^9.1.3 + version: 9.2.1(@babel/core@7.25.2)(webpack@5.92.1(@swc/core@1.7.26)(esbuild@0.23.1)) + babel-preset-modern-browser-extension: + specifier: ^0.7.0 + version: 0.7.0(@babel/core@7.25.2) + stylelint: + specifier: ^16.7.0 + version: 16.9.0(typescript@5.3.3) + + examples/new-config-eslint: + devDependencies: + '@eslint/js': + specifier: ^9.6.0 + version: 9.11.0 + eslint: + specifier: ^9.6.0 + version: 9.11.0(jiti@1.21.6) + globals: + specifier: ^15.9.0 + version: 15.9.0 + typescript: + specifier: 5.3.3 + version: 5.3.3 + typescript-eslint: + specifier: ^8.5.0 + version: 8.6.0(eslint@9.11.0(jiti@1.21.6))(typescript@5.3.3) + + examples/new-config-lint: + devDependencies: + '@eslint/js': + specifier: ^9.6.0 + version: 9.11.0 + eslint: + specifier: ^9.6.0 + version: 9.11.0(jiti@1.21.6) + eslint-config-prettier: + specifier: ^9.1.0 + version: 9.1.0(eslint@9.11.0(jiti@1.21.6)) + globals: + specifier: ^15.9.0 + version: 15.9.0 + prettier: + specifier: ^3.3.2 + version: 3.3.3 + stylelint: + specifier: ^16.7.0 + version: 16.9.0(typescript@5.3.3) + typescript: + specifier: 5.3.3 + version: 5.3.3 + typescript-eslint: + specifier: ^8.5.0 + version: 8.6.0(eslint@9.11.0(jiti@1.21.6))(typescript@5.3.3) + + examples/new-config-prettier: + devDependencies: + prettier: + specifier: ^3.3.2 + version: 3.3.3 + + examples/new-config-stylelint: + devDependencies: + sass: + specifier: ^1.77.8 + version: 1.79.2 + stylelint: + specifier: ^16.7.0 + version: 16.9.0(typescript@5.3.3) + stylelint-config-standard-scss: + specifier: ^13.1.0 + version: 13.1.0(postcss@8.4.47)(stylelint@16.9.0(typescript@5.3.3)) + examples/new-crypto: devDependencies: node-polyfill-webpack-plugin: @@ -364,6 +358,15 @@ importers: specifier: ^4.2.0 version: 4.2.0 + examples/new-node-apis: + devDependencies: + node-polyfill-webpack-plugin: + specifier: ^4.0.0 + version: 4.0.0(webpack@5.92.1(@swc/core@1.7.26)(esbuild@0.23.1)) + typescript: + specifier: 5.3.3 + version: 5.3.3 + examples/new-preact: dependencies: '@preact/signals': diff --git a/programs/develop/build.spec.ts b/programs/develop/build.spec.ts index 923a8697..c08cd786 100644 --- a/programs/develop/build.spec.ts +++ b/programs/develop/build.spec.ts @@ -172,7 +172,7 @@ describe('extension build', () => { templatePath, 'dist', SUPPORTED_BROWSERS[0], - `${template.name}-template-0.0.1.zip` + `${template.name}-0.0.1.zip` ) ) ).toBeTruthy() @@ -199,11 +199,7 @@ describe('extension build', () => { expect( fs.existsSync( - path.join( - templatePath, - 'dist', - `${template.name}-template-0.0.1-source.zip` - ) + path.join(templatePath, 'dist', `${template.name}-0.0.1-source.zip`) ) ).toBeTruthy() }, diff --git a/programs/develop/webpack/plugin-extension/feature-html/steps/emit-html-file.ts b/programs/develop/webpack/plugin-extension/feature-html/steps/emit-html-file.ts index 379ef717..80e06705 100644 --- a/programs/develop/webpack/plugin-extension/feature-html/steps/emit-html-file.ts +++ b/programs/develop/webpack/plugin-extension/feature-html/steps/emit-html-file.ts @@ -19,7 +19,9 @@ export class EmitHtmlFile { public apply(compiler: Compiler): void { const manifest = require(this.manifestPath) - const manifestName = manifest.name || 'Extension.js' + const patchedManifest = utils.filterKeysForThisBrowser(manifest, 'chrome') + + const manifestName = patchedManifest.name || 'Extension.js' compiler.hooks.thisCompilation.tap('html:emit-html-file', (compilation) => { compilation.hooks.processAssets.tap( diff --git a/programs/develop/webpack/plugin-extension/feature-html/steps/throw-if-recompile-is-needed.ts b/programs/develop/webpack/plugin-extension/feature-html/steps/throw-if-recompile-is-needed.ts index 15545e5e..8880cb6b 100644 --- a/programs/develop/webpack/plugin-extension/feature-html/steps/throw-if-recompile-is-needed.ts +++ b/programs/develop/webpack/plugin-extension/feature-html/steps/throw-if-recompile-is-needed.ts @@ -2,6 +2,7 @@ import fs from 'fs' import {type Compiler} from 'webpack' import {type FilepathList, type PluginInterface} from '../../../webpack-types' import {getAssetsFromHtml} from '../html-lib/utils' +import * as utils from '../../../lib/utils' import * as messages from '../../../lib/messages' export class ThrowIfRecompileIsNeeded { @@ -38,7 +39,12 @@ export class ThrowIfRecompileIsNeeded { if (htmlFile) { if (!fs.existsSync(htmlFile)) { const manifest = require(this.manifestPath) - const manifestName = manifest.name || 'Extension.js' + const patchedManifest = utils.filterKeysForThisBrowser( + manifest, + 'chrome' + ) + + const manifestName = patchedManifest.name || 'Extension.js' console.error( messages.manifestFieldError(manifestName, key, htmlFile) ) diff --git a/programs/develop/webpack/plugin-extension/feature-locales/__spec__/index.spec.ts b/programs/develop/webpack/plugin-extension/feature-locales/__spec__/index.spec.ts index 3b2a1e1a..0c6f8151 100644 --- a/programs/develop/webpack/plugin-extension/feature-locales/__spec__/index.spec.ts +++ b/programs/develop/webpack/plugin-extension/feature-locales/__spec__/index.spec.ts @@ -35,7 +35,7 @@ export const findStringInFile = async ( } describe('LocalesPlugin', () => { - const fixturesPath = getFixturesPath('locales') + const fixturesPath = getFixturesPath('action-locales') const outputPath = path.resolve(fixturesPath, 'dist', 'chrome') beforeAll(async () => { diff --git a/programs/develop/webpack/plugin-extension/feature-locales/index.ts b/programs/develop/webpack/plugin-extension/feature-locales/index.ts index 251e12c3..ff22aba2 100644 --- a/programs/develop/webpack/plugin-extension/feature-locales/index.ts +++ b/programs/develop/webpack/plugin-extension/feature-locales/index.ts @@ -34,11 +34,16 @@ export class LocalesPlugin { stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS }, () => { - const manifest = require(this.manifestPath) - const manifestName = manifest.name || 'Extension.js' - // Do not emit if manifest doesn't exist. if (!fs.existsSync(this.manifestPath)) { + const manifest = require(this.manifestPath) + const patchedManifest = utils.filterKeysForThisBrowser( + manifest, + 'chrome' + ) + + const manifestName = patchedManifest.name || 'Extension.js' + compilation.errors.push( new webpack.WebpackError( messages.manifestNotFoundError(manifestName, this.manifestPath) diff --git a/programs/develop/webpack/plugin-extension/feature-manifest/steps/check-manifest-files.ts b/programs/develop/webpack/plugin-extension/feature-manifest/steps/check-manifest-files.ts index a9efc28a..50f8bc93 100644 --- a/programs/develop/webpack/plugin-extension/feature-manifest/steps/check-manifest-files.ts +++ b/programs/develop/webpack/plugin-extension/feature-manifest/steps/check-manifest-files.ts @@ -1,6 +1,7 @@ import fs from 'fs' import path from 'path' import webpack, {Compilation, Compiler} from 'webpack' +import * as utils from '../../../lib/utils' import * as messages from '../../../lib/messages' import {PluginInterface, FilepathList} from '../../../webpack-types' @@ -60,7 +61,12 @@ export class CheckManifestFiles { for (const item of valueArr) { const ext = path.extname(item as string) const manifest = require(this.manifestPath) - const manifestName = manifest.name || 'Extension.js' + const patchedManifest = utils.filterKeysForThisBrowser( + manifest, + 'chrome' + ) + + const manifestName = patchedManifest.name || 'Extension.js' if (!fs.existsSync(item as string)) { // Assume that by refrencing an absolute path, the user diff --git a/programs/develop/webpack/plugin-extension/feature-scripts/steps/add-public-path-for-main-world.ts b/programs/develop/webpack/plugin-extension/feature-scripts/steps/add-public-path-for-main-world.ts index 07e6c850..30366287 100644 --- a/programs/develop/webpack/plugin-extension/feature-scripts/steps/add-public-path-for-main-world.ts +++ b/programs/develop/webpack/plugin-extension/feature-scripts/steps/add-public-path-for-main-world.ts @@ -5,7 +5,8 @@ import { type Manifest } from '../../../webpack-types' import * as messages from '../../../lib/messages' -import {DevOptions} from '../../../../module' +import * as utils from '../../../lib/utils' +import {DevOptions} from '../../../../commands/dev' import {CHROMIUM_BASED_BROWSERS} from '../../../lib/constants' export class AddPublicPathForMainWorld { @@ -22,7 +23,12 @@ export class AddPublicPathForMainWorld { } public apply(_compiler: Compiler): void { - const manifest: Manifest = require(this.manifestPath) + const initialManifest: Manifest = require(this.manifestPath) + const manifest = utils.filterKeysForThisBrowser( + initialManifest, + this.browser + ) + if ( manifest.content_scripts?.some( // @ts-expect-error - TS doesn't know about content_scripts diff --git a/programs/develop/webpack/plugin-reload/steps/setup-reload-strategy/target-web-extension-plugin/index.ts b/programs/develop/webpack/plugin-reload/steps/setup-reload-strategy/target-web-extension-plugin/index.ts index 79cc2395..628ce702 100644 --- a/programs/develop/webpack/plugin-reload/steps/setup-reload-strategy/target-web-extension-plugin/index.ts +++ b/programs/develop/webpack/plugin-reload/steps/setup-reload-strategy/target-web-extension-plugin/index.ts @@ -77,8 +77,14 @@ export class TargetWebExtensionPlugin { private ensureFileExists(filePath: string) { if (!fs.existsSync(filePath)) { if (this.manifestPath) { - const manifest: Manifest = require(this.manifestPath) - const manifestName = manifest.name || 'Extension.js' + const manifest = require(this.manifestPath) + const patchedManifest = utils.filterKeysForThisBrowser( + manifest, + 'chrome' + ) + + const manifestName = patchedManifest.name || 'Extension.js' + const fieldError = messages.backgroundIsRequired(manifestName, filePath) console.error(fieldError) throw new Error(fieldError)