Comments (3)
Wow that's a super fancy things to do for inject something. 😆
Thanks!
from browser-extension-react-typescript-starter.
Thank you for reaching out. I am sharing an example setup that I created for one of my clients.
You can create the main injection script in content/injection
folder.
(or wherever you want to structure it, crxjs
and vite
handle it. see: https://github.com/crxjs/chrome-extension-tools)
And you can import it inside content/index.ts
import pageContextInject from './injection/pageContextInject?script&module';
const setupInjectPageContextScript = () => {
const s = document.createElement('script');
s.src = chrome.runtime.getURL(pageContextInject);
s.type = 'module';
document.head.appendChild(s);
s.onload = function () {
s.remove();
};
};
And at the end
(async function initialize() {
const config = await getExtensionConfig();
if (config.enabled) {
//setupInitialDispatch();
setupInjectPageContextScript();
//setupInjections();
//setupSomeOther();
}
})();
Hope you find it useful.
from browser-extension-react-typescript-starter.
@katopz you may need to add this code to typings.d.ts
to make tsc
happy. see: https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations
https://vitejs.dev/guide/assets.html#importing-asset-as-url
declare module '*?script&module' {
const src: string;
export default src;
}
from browser-extension-react-typescript-starter.
Related Issues (9)
- Dependency Dashboard
- CSS Modules not reloading HOT 3
- 'TS_NODE_COMPILER_OPTIONS' is not recognized as an internal or external command, operable program or batch file.
- Service worker registration failed. Status code: 3 (latest version of vite) HOT 1
- How to use v3 in FireFox? HOT 8
- How do you upload the result? HOT 1
- CSP Issue when running HMR-enabled dev build on Firefox 117.0 HOT 1
- storage: createJSONStorage(() => localstorage) may lost data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browser-extension-react-typescript-starter.