diff --git a/components.d.ts b/components.d.ts
index 7813ecc..b4c573d 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -14,6 +14,7 @@ declare module '@vue/runtime-core' {
IconEcosystem: typeof import('./src/components/icons/IconEcosystem.vue')['default']
IconSupport: typeof import('./src/components/icons/IconSupport.vue')['default']
IconTooling: typeof import('./src/components/icons/IconTooling.vue')['default']
+ PixelarticonsPower: typeof import('~icons/pixelarticons/power')['default']
TheWelcome: typeof import('./src/components/TheWelcome.vue')['default']
WelcomeItem: typeof import('./src/components/WelcomeItem.vue')['default']
}
diff --git a/manifest.json b/manifest.json
index 83ba44a..fa00bde 100644
--- a/manifest.json
+++ b/manifest.json
@@ -3,6 +3,12 @@
"name": "CRXJS Vue Vite Example",
"version": "1.0.0",
"action": { "default_popup": "src/popup/index.html" },
+ "content_scripts": [
+ {
+ "js": ["src/contentScripts/index.ts"],
+ "matches": ["https://*/*"]
+ }
+ ],
"options_ui": {
"page": "src/options/index.html",
"open_in_tab": true
diff --git a/package.json b/package.json
index 49739f2..86a9cc6 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,8 @@
},
"dependencies": {
"@vueuse/core": "^9.1.1",
- "vue": "^3.2.37"
+ "vue": "^3.2.37",
+ "webext-bridge": "^5.0.5"
},
"devDependencies": {
"@crxjs/vite-plugin": "^1.0.14",
@@ -22,7 +23,7 @@
"@types/jsdom": "^20.0.0",
"@types/node": "^16.11.47",
"@types/webextension-polyfill": "^0.9.0",
- "@vitejs/plugin-vue": "^3.0.1",
+ "@vitejs/plugin-vue": "^2.3.2",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^11.0.0",
"@vue/test-utils": "^2.0.2",
@@ -36,7 +37,7 @@
"unplugin-auto-import": "^0.11.2",
"unplugin-icons": "^0.14.8",
"unplugin-vue-components": "^0.22.4",
- "vite": "^3.0.4",
+ "vite": "^2.9.15",
"vite-plugin-windicss": "^1.8.7",
"vitest": "^0.21.0",
"vue-tsc": "^0.39.5",
diff --git a/src/App.vue b/src/App.vue
deleted file mode 100644
index d74af10..0000000
--- a/src/App.vue
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue
deleted file mode 100644
index c52e909..0000000
--- a/src/components/HelloWorld.vue
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
- {{ msg }}
-
-
- You’ve successfully created a project with
- Vite +
- Vue 3 .
-
-
-
-
-
diff --git a/src/components/TheWelcome.vue b/src/components/TheWelcome.vue
deleted file mode 100644
index 2aad30c..0000000
--- a/src/components/TheWelcome.vue
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
- Documentation
-
- Vue’s
- official documentation
- provides you with all information you need to get started.
-
-
-
-
-
-
- Tooling
-
- This project is served and bundled with
- Vite .
- The recommended IDE setup is
- VSCode +
- Volar .
- If you need to test your components and web pages, check out
- Cypress and
- Cypress Component Testing .
-
-
-
- More instructions are available in README.md
.
-
-
-
-
-
-
- Ecosystem
-
- Get official tools and libraries for your project:
- Pinia ,
- Vue Router ,
- Vue Test Utils ,
- and
- Vue Dev Tools . If you need more resources, we suggest paying
- Awesome Vue
- a visit.
-
-
-
-
-
-
- Community
-
- Got stuck? Ask your question on
- Vue Land , our official
- Discord server, or
- StackOverflow . You should also subscribe to
- our mailing list and
- follow the official
- @vuejs
- twitter account for latest news in the Vue world.
-
-
-
-
-
-
- Support Vue
-
- As an independent project, Vue relies on community backing for its
- sustainability. You can help us by
- becoming a sponsor .
-
-
diff --git a/src/components/WelcomeItem.vue b/src/components/WelcomeItem.vue
deleted file mode 100644
index ba0def3..0000000
--- a/src/components/WelcomeItem.vue
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
diff --git a/src/components/__tests__/HelloWorld.spec.ts b/src/components/__tests__/HelloWorld.spec.ts
deleted file mode 100644
index f7b12f0..0000000
--- a/src/components/__tests__/HelloWorld.spec.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { describe, it, expect } from 'vitest';
-
-import { mount } from '@vue/test-utils';
-import HelloWorld from '../HelloWorld.vue';
-
-describe('HelloWorld', () => {
- it('renders properly', () => {
- const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } });
- expect(wrapper.text()).toContain('Hello Vitest');
- });
-});
diff --git a/src/components/icons/IconCommunity.vue b/src/components/icons/IconCommunity.vue
deleted file mode 100644
index ea8ddef..0000000
--- a/src/components/icons/IconCommunity.vue
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/src/components/icons/IconDocumentation.vue b/src/components/icons/IconDocumentation.vue
deleted file mode 100644
index 63a8534..0000000
--- a/src/components/icons/IconDocumentation.vue
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/src/components/icons/IconEcosystem.vue b/src/components/icons/IconEcosystem.vue
deleted file mode 100644
index 385a202..0000000
--- a/src/components/icons/IconEcosystem.vue
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/src/components/icons/IconSupport.vue b/src/components/icons/IconSupport.vue
deleted file mode 100644
index 7db961e..0000000
--- a/src/components/icons/IconSupport.vue
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
diff --git a/src/components/icons/IconTooling.vue b/src/components/icons/IconTooling.vue
deleted file mode 100644
index 660598d..0000000
--- a/src/components/icons/IconTooling.vue
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
diff --git a/src/contentScripts/app.css b/src/contentScripts/app.css
new file mode 100644
index 0000000..310c96a
--- /dev/null
+++ b/src/contentScripts/app.css
@@ -0,0 +1,3 @@
+h1.test {
+ background-color: beige;
+}
diff --git a/src/contentScripts/index.ts b/src/contentScripts/index.ts
new file mode 100644
index 0000000..eff7b4e
--- /dev/null
+++ b/src/contentScripts/index.ts
@@ -0,0 +1,58 @@
+/* eslint-disable no-console */
+import { onMessage } from 'webext-bridge';
+import { createApp } from 'vue';
+import vws from 'virtual:windi.css?inline';
+import appCss from './app.css?inline';
+
+// eslint-disable-next-line
+// @ts-ignore
+import App from './views/App.vue';
+
+// Firefox `browser.tabs.executeScript()` requires scripts return a primitive value
+(() => {
+ console.info('[vitesse-webext] Hello world from content script');
+ console.log(appCss, vws);
+
+ // communication example: send previous tab title from background page
+ onMessage('tab-prev', ({ data }) => {
+ // console.log(`[vitesse-webext] Navigate from page "${data.title}"`);
+ });
+
+ // mount component to context window
+ const container = document.createElement('div');
+ const root = document.createElement('div');
+ const styleWindi = document.createElement('script');
+ // styleWindi.textContent = vws;
+
+ const styleApp = document.createElement('script');
+ // styleApp.textContent = appCss;
+ /* const shadowDOM =
+ container.attachShadow?.({ mode: __DEV__ ? 'open' : 'closed' }) ||
+ container; */
+ const shadowDOM = container.attachShadow?.({ mode: 'closed' }) || container;
+ // styleWindi.setAttribute('src', 'stylesheet');
+ styleWindi.setAttribute(
+ 'src',
+ // eslint-disable-next-line
+ // @ts-ignore
+ browser.runtime.getURL(appCss),
+ // appCss,
+ );
+
+ shadowDOM.appendChild(styleWindi);
+ shadowDOM.appendChild(styleApp);
+ shadowDOM.appendChild(root);
+ document.body.appendChild(container);
+ createApp(App).mount(root);
+
+ if (import.meta.hot) {
+ import.meta.hot.on('vite:beforeUpdate', (newModule) => {
+ if (
+ newModule.type === 'update' &&
+ newModule.updates.some((u) => u.path.includes('windi.css.js'))
+ ) {
+ console.log(`Receving new module...`, newModule);
+ }
+ });
+ }
+})();
diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue
new file mode 100644
index 0000000..caca0b7
--- /dev/null
+++ b/src/contentScripts/views/App.vue
@@ -0,0 +1,35 @@
+
+
+
+
+
Test
+
+ Vitesse WebExt23
+
+
+
+
+
+
diff --git a/src/main.ts b/src/main.ts
deleted file mode 100644
index 39d3e97..0000000
--- a/src/main.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createApp } from 'vue';
-import App from './App.vue';
-
-import './assets/main.css';
-
-createApp(App).mount('#app');
diff --git a/yarn.lock b/yarn.lock
index cc9131b..f2fea7a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -494,6 +494,11 @@
resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.15.tgz#d60330046a6ed8a13b4a53df3813c44942ebdf72"
integrity sha512-w7hEHXnPMEZ+4nGKl/KDRVpxkwYxYExuHOYXyzIzCDzEZ9ZCGMAewulr9IqJu2LR4N37fcnb1XVeuZ09qgOxhA==
+"@types/webextension-polyfill@^0.8.3":
+ version "0.8.3"
+ resolved "https://registry.yarnpkg.com/@types/webextension-polyfill/-/webextension-polyfill-0.8.3.tgz#eb601b3fcf524f0ecf7d7579ccbd237928d0dda7"
+ integrity sha512-GN+Hjzy9mXjWoXKmaicTegv3FJ0WFZ3aYz77Wk8TMp1IY3vEzvzj1vnsa0ggV7vMI1i+PUxe4qqnIJKCzf9aTg==
+
"@types/webextension-polyfill@^0.9.0":
version "0.9.0"
resolved "https://registry.yarnpkg.com/@types/webextension-polyfill/-/webextension-polyfill-0.9.0.tgz#a50b5f03161ef83e46721719b49668cfcaac804a"
@@ -593,10 +598,10 @@
magic-string "^0.26.2"
react-refresh "^0.14.0"
-"@vitejs/plugin-vue@^3.0.1":
- version "3.0.3"
- resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-3.0.3.tgz#7e3e401ccb30b4380d2279d9849281413f1791ef"
- integrity sha512-U4zNBlz9mg+TA+i+5QPc3N5lQvdUXENZLO2h0Wdzp56gI1MWhqJOv+6R+d4kOzoaSSq6TnGPBdZAXKOe4lXy6g==
+"@vitejs/plugin-vue@^2.3.2":
+ version "2.3.4"
+ resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-2.3.4.tgz#966a6279060eb2d9d1a02ea1a331af071afdcf9e"
+ integrity sha512-IfFNbtkbIm36O9KB8QodlwwYvTEsJb4Lll4c2IwB3VHc2gie2mSPtSzL0eYay7X2jd/2WX02FjSGTWR6OPr/zg==
"@volar/code-gen@0.39.5":
version "0.39.5"
@@ -1441,7 +1446,7 @@ esbuild-windows-arm64@0.14.54:
resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.54.tgz#937d15675a15e4b0e4fafdbaa3a01a776a2be982"
integrity sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==
-esbuild@^0.14.47:
+esbuild@^0.14.27, esbuild@^0.14.47:
version "0.14.54"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.54.tgz#8b44dcf2b0f1a66fc22459943dccf477535e9aa2"
integrity sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==
@@ -2391,6 +2396,11 @@ ms@2.1.2:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
+nanoevents@^6.0.2:
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/nanoevents/-/nanoevents-6.0.2.tgz#3824031c7beab754b04ae5a17936c0fc7b6a183c"
+ integrity sha512-FRS2otuFcPPYDPYViNWQ42+1iZqbXydinkRHTHFxrF4a1CpBfmydR9zkI44WSXAXCyPrkcGtPk5CnpW6Y3lFKQ==
+
nanoid@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
@@ -2646,7 +2656,7 @@ postcss-selector-parser@^6.0.9:
cssesc "^3.0.0"
util-deprecate "^1.0.2"
-postcss@^8.1.10, postcss@^8.4.16:
+postcss@^8.1.10, postcss@^8.4.13, postcss@^8.4.16:
version "8.4.16"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.16.tgz#33a1d675fac39941f5f445db0de4db2b6e01d43c"
integrity sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==
@@ -2752,7 +2762,7 @@ resolve-from@^4.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
-resolve@^1.10.0, resolve@^1.22.1:
+resolve@^1.10.0, resolve@^1.22.0, resolve@^1.22.1:
version "1.22.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177"
integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==
@@ -2773,7 +2783,7 @@ rimraf@^3.0.2:
dependencies:
glob "^7.1.3"
-"rollup@>=2.75.6 <2.77.0 || ~2.77.0":
+"rollup@>=2.59.0 <2.78.0", "rollup@>=2.75.6 <2.77.0 || ~2.77.0":
version "2.77.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.77.3.tgz#8f00418d3a2740036e15deb653bed1a90ee0cc12"
integrity sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==
@@ -2833,6 +2843,13 @@ semver@^7.3.5, semver@^7.3.6, semver@^7.3.7:
dependencies:
lru-cache "^6.0.0"
+serialize-error@^9.0.0:
+ version "9.1.1"
+ resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-9.1.1.tgz#b66744b6287b538996a153103e67af7179d0831a"
+ integrity sha512-6uZQLGyUkNA4N+Zii9fYukmNu9PEA1F5rqcwXzN/3LtBjwl2dFBbVZ1Zyn08/CGkB4H440PIemdOQBt1Wvjbrg==
+ dependencies:
+ type-fest "^2.5.3"
+
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
@@ -3012,6 +3029,11 @@ text-table@^0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==
+tiny-uid@^1.1.1:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/tiny-uid/-/tiny-uid-1.1.2.tgz#6ccf1bd9877151daedada63f896a4b20d315c0dc"
+ integrity sha512-0beRFXR+fv4C40ND2PqgNjq6iyB1dKXciKJjslLw0kPYCcR82aNd2b+Tt2yy06LimIlvtoehgvrm/fUZCutSfg==
+
tinypool@^0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/tinypool/-/tinypool-0.2.4.tgz#4d2598c4689d1a2ce267ddf3360a9c6b3925a20c"
@@ -3087,6 +3109,11 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
+type-fest@^2.5.3:
+ version "2.19.0"
+ resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.19.0.tgz#88068015bb33036a598b952e55e9311a60fd3a9b"
+ integrity sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==
+
typescript@~4.7.4:
version "4.7.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
@@ -3245,7 +3272,7 @@ vite-plugin-windicss@^1.8.7:
kolorist "^1.5.1"
windicss "^3.5.6"
-"vite@^2.9.12 || ^3.0.0-0", vite@^3.0.4:
+"vite@^2.9.12 || ^3.0.0-0":
version "3.0.9"
resolved "https://registry.yarnpkg.com/vite/-/vite-3.0.9.tgz#45fac22c2a5290a970f23d66c1aef56a04be8a30"
integrity sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==
@@ -3257,6 +3284,18 @@ vite-plugin-windicss@^1.8.7:
optionalDependencies:
fsevents "~2.3.2"
+vite@^2.9.15:
+ version "2.9.15"
+ resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.15.tgz#2858dd5b2be26aa394a283e62324281892546f0b"
+ integrity sha512-fzMt2jK4vQ3yK56te3Kqpkaeq9DkcZfBbzHwYpobasvgYmP2SoAr6Aic05CsB4CzCZbsDv4sujX3pkEGhLabVQ==
+ dependencies:
+ esbuild "^0.14.27"
+ postcss "^8.4.13"
+ resolve "^1.22.0"
+ rollup ">=2.59.0 <2.78.0"
+ optionalDependencies:
+ fsevents "~2.3.2"
+
vitest@^0.21.0:
version "0.21.1"
resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.21.1.tgz#b4f5b901c9a23a3aaec76d3404f3072821d93d00"
@@ -3323,11 +3362,27 @@ w3c-xmlserializer@^3.0.0:
dependencies:
xml-name-validator "^4.0.0"
+webext-bridge@^5.0.5:
+ version "5.0.5"
+ resolved "https://registry.yarnpkg.com/webext-bridge/-/webext-bridge-5.0.5.tgz#1465135343fbe5ee944323294ac90cd97b663304"
+ integrity sha512-STCv6pLfQtUHmZQ96Tmov+CrdGjjc08xG6o/VH7TlDvchAPmXEG7faPdHfIzkcs0qp0sedDkq7oDzXAei19vtw==
+ dependencies:
+ "@types/webextension-polyfill" "^0.8.3"
+ nanoevents "^6.0.2"
+ serialize-error "^9.0.0"
+ tiny-uid "^1.1.1"
+ webextension-polyfill "^0.9.0"
+
webextension-polyfill@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz#ccb28101c910ba8cf955f7e6a263e662d744dbb8"
integrity sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g==
+webextension-polyfill@^0.9.0:
+ version "0.9.0"
+ resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.9.0.tgz#de6c1941d0ef1b0858b20e9c7b46bbc042c5a960"
+ integrity sha512-LTtHb0yR49xa9irkstDxba4GATDAcDw3ncnFH9RImoFwDlW47U95ME5sn5IiQX2ghfaECaf6xyXM8yvClIBkkw==
+
webidl-conversions@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a"