GithubHelp home page GithubHelp logo

mubaidr / vite-vue3-chrome-extension-v3 Goto Github PK

View Code? Open in Web Editor NEW
366.0 4.0 48.0 608 KB

Another vite powered web extension (chrome, firefox, etc.) starter template.

JavaScript 6.67% TypeScript 57.25% HTML 6.09% Vue 26.84% SCSS 3.15%
chrome extension vite vue3 webextension hacktoberfest

vite-vue3-chrome-extension-v3's People

Contributors

baramofme avatar dependabot[bot] avatar github-actions[bot] avatar justorez avatar mubaidr avatar poncianodiego avatar ultimateshadsform avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vite-vue3-chrome-extension-v3's Issues

pnpm dev results in an error with fresh install

I've installed a fresh instance of this repo and when I run pnpm dev I get this response:

[vite:css] [postcss] Cannot read properties of undefined (reading 'config') file: /__uno.css:undefined:undefined

I can successfully run this repo if I remove the tailwindcss: {}, from postcss.config.cjs

Any ideas on how to fix?

TODO Update to Vite 5

I have seen https://github.com/crxjs/chrome-extension-tools has updated and fixed the Vite 5 problem with @crxjs/[email protected] version.

crxjs/chrome-extension-tools@ce9fe1c: Fix/web accessible resources script modules
crxjs/chrome-extension-tools@48d8c68: Vite 5 moved vite manifest from 'manifest.json' to
'.vite/manifest.json'. This change updates the plugin to use the new location
if Vite major version is >4, old location otherwise.

I haven't tested it yet but it's a goal.

[bug] Failed to load picture

截屏2023-03-04 10 15 28

I just clone the template and run command pnpm dev, and the vue's logo is broken.

I guess it needs to be placed in public folder?

My platform and os: chrome, mac

Migrate to Nuxt

  • File-based Routing
  • Modular Architecture
  • Automatic Code Splitting
  • Nuxt layers for sharing base configuration/ design between all extension pages

Global error handling to avoid extension context issues

This ensures errors are logged, but extension context is not disconnected.

self.onerror = function (message, source, lineno, colno, error) {
  console.info(
    `Error: ${message}\nSource: ${source}\nLine: ${lineno}\nColumn: ${colno}\nError object: ${error}`
  )
}

Popup page shows Options page

I build source and load it on chrome.

And then I found Popup shows Options page.

Options show it self That's fine.

options.html

    <script type="module" crossorigin src="..\..\assets/index.html-74b33acf.js"></script>
    <link rel="modulepreload" crossorigin href="..\..\assets/base-176afb78.js">

popup.html

    <script type="module" crossorigin src="..\..\assets/index.html-02ab7c9c.js"></script>
    <link rel="modulepreload" crossorigin href="..\..\assets/base-176afb78.js">

common ref is base-176afb78.js. so I investigated.

base-176afb78.js


// It's options.html content
// and lu render options.html contents
function iu(e, t) {
    return so(), oo(xe, null, [hs(" 옵션 페이지 "), ou], 64)
}
const lu = Co(su, [["render", iu], ["__scopeId", "data-v-a4d9e10f"]]);


// It's popup.html content
// du is render popup.html content
function au(e, t) {
    return so(), oo(xe, null, [uu, hs(" 팝업 페이지 "), fu], 64)
}
const du = Co(cu, [["render", au], ["__scopeId", "data-v-15bb346d"]]),


// and root path mapping only options page component (lu).
bu = [{path: "/", component: lu, 
children: [{name: "index", path: "", component: du, props: !0}], props: !0}];
export {Co as _, _u as a, mu as b, pu as c, bu as d, gu as e, so as o, hu as r};

I don't know why, but router info and each app.vue has merged.
so that, when popupt.html trying to access root path. router returns only option pages component.

error when starting the project: __DISPLAY_NAME__ is not defined

Hello,

I am very interested in this starter/template project for building some vue/vite powered browser extensions.

When i start the project with

npm run dev it starts fine.

I then try to load the chrome extension from the dist folder as instructed but it shows me:

Uncaught ReferenceError: __DISPLAY_NAME__ is not defined
    at app.vue:12:27
    at callWithErrorHandling (chunk-HS45CFH5.js?v=81710182:1659:19)
    at callWithAsyncErrorHandling (chunk-HS45CFH5.js?v=81710182:1666:17)
    at ReactiveEffect.getter [as fn] (chunk-HS45CFH5.js?v=81710182:3361:16)
    at ReactiveEffect.run (chunk-HS45CFH5.js?v=81710182:435:19)
    at doWatch (chunk-HS45CFH5.js?v=81710182:3462:13)
    at watchEffect (chunk-HS45CFH5.js?v=81710182:3256:10)
    at setup (app.vue:9:1)
    at callWithErrorHandling (chunk-HS45CFH5.js?v=81710182:1659:19)
    at setupStatefulComponent (chunk-HS45CFH5.js?v=81710182:9073:25)
image

I have tried adding the .env file with the following:

__DISPLAY_NAME__=TEST
__DISPLAY_VERSION__=1.0.0
__DISPLAY_DESCRIPTION__=Test
__DISPLAY_AUTHOR__=Test

But still the browser does not seem to accept the extension.

Thank you for your time!

Fix for the src problem

I have finally fixed it!

Move all html files outside src folder like this:

image

Add setup page to rollup:
image

Change ts path inside all html files to relative ts file:
image

Now everything works as expected:
image

content-script does not use iframe, style issue

content-script/index.ts code

import { createApp } from 'vue'
import App from './content/app.vue'
import './index.scss'

const container = document.createElement('div')
container.id = 'test' 
container.className = 'test' 

const root = document.createElement('div')
root.id = 'test-app'


const shadowDOM = container.attachShadow?.({ mode: 'open' }) || container
shadowDOM.appendChild(root)


document.body.appendChild(container)


const app = createApp(App)

app.config.globalProperties.$app = {
  context: '',
}


app.provide('app', app.config.globalProperties.$app)


app.mount(root)

content-script/content/app.vue

<template>
  <div class="testqwe">
    <div
      class="floating-text"
      style="font-size: 50px; color: red"
    >
      test
    </div>
  </div>
</template>
<style lang="scss">
.floating-text {
 position: fixed;
  top: 50%;
   left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  font-weight: bold;
   padding: 10px;
   background-color: rgba(0, 0, 0, 0.5);
   color: white;
   border-radius: 5px;
}
.testqwe {
  background-color: #ffffff;
}

Neither the styles in index.scss nor the styles in style lang='scss' are taking effect, only the inline styles mentioned above are working. Why is this happening?
I want to create a floating content that appears in the middle of the page, without using an iframe.

Question: image paths inside vue components

First of all, great template!

Question: instead of relative image paths like

<img src="../../assets/vite.svg" />

Would it be possible to use the alias defined in vite.config.ts?

<img src="src/assets/vite.svg" />

It's not working with the current setup.

limited to iframe size

"Hello, I'm creating a button in a content-script with a fixed position. Everything is working great. But I need a modal window to be displayed across the entire screen when this button is clicked. However, I'm limited by the dimensions of the iframe. What should I do?"

Chrome V3 Refused to execute inline script ...

Hi,

thank you very much for providing a great Chrome plugin template. This is when I opened a new window using the V3 version through [chrome.tabs.create] and executed a JavaScript code, the console encountered an error as follows:

image

After trying, I still cannot solve this problem until now...
Can you help me solve this problem? Thank you 🙏

Inject into content script

Thank you for this great project!
Can you guide me how to inject popup into content script? I want to show the whole popup into website page.

Add Prefix To Isolate Source Website And Our Plugin

Thank you for such an awesome project🥰! While using it, I've run into some issues, like class name conflicts between Tailwind CSS and the original website's styles.
I think it can add a prefix(to the tailwindcss) by Custom Directives of Vue to isolate the source website and our Chrome plugin like this:

<div v-prefix-class="flex flex-col ...">
  ...
</div>

and it will be:

<div class="custom-prefix-flex custom-prefix-flex-col ...">
  ...
</div>

or we can use some building utils like postcss to add prefix autoly.
What's your take on the two solutions above? If it's feasible, I can try to code it.

promise error message

I am running pnpm dev in the console with no errors but when I look in the chrome extensions( console )
I see this error. Any ideas on how to fix?
error_2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.