Git Product home page Git Product logo

Comments (10)

theharshin avatar theharshin commented on August 15, 2024 1

image

After removing this check, everything works fine.

from vue-cli-plugin-browser-extension.

rrfaria avatar rrfaria commented on August 15, 2024 1

I opened a PR suggesting this change
#64

from vue-cli-plugin-browser-extension.

theharshin avatar theharshin commented on August 15, 2024

I've tried to use v0.19.0 with the same setup and everything works fine! 🤔

from vue-cli-plugin-browser-extension.

adambullmer avatar adambullmer commented on August 15, 2024

Can you share you vue.config.js file and your src/manifest.json? Also how are you trying to invoke your content scripts and background scripts?

from vue-cli-plugin-browser-extension.

rrfaria avatar rrfaria commented on August 15, 2024

I found out the problem is not in the code please discard this PR.

the plugin even you are selecting content-script in options, it doesn't add on src/manifest.json and only vue.config.js is right

"content_scripts": [
    {
      "matches": ["*://*/*"],
      "js": ["js/content-script.js"]
    }
  ],

from vue-cli-plugin-browser-extension.

adambullmer avatar adambullmer commented on August 15, 2024

Correct. The snippet you added automatically injects a content script into every page. It is my opinion that this behavior should not be the default scaffolding behavior of browser extensions, as most developers will probably never circle back and change this to a narrower list if they didn't need it in the first place.

That being said, if this continues to be a pain point, then this means there is a difference in expectations of this plugin between myself and the community, or a lapse in documentation around this particular feature. Probably a good first step is to highlight this fact in the readme and see if there continues to be issues around expecting automatically injected content scripts on every page.

from vue-cli-plugin-browser-extension.

rrfaria avatar rrfaria commented on August 15, 2024

@adambullmer I believe the misunderstood is happen because when you are creating your first extension there are some options you can choose and when you select "content-script" between them we were expecting no need to setup more things to run it.

sorry for that.

One thing I would like to say is your work is amazing it is helping a lot.

from vue-cli-plugin-browser-extension.

JasonLearmouth avatar JasonLearmouth commented on August 15, 2024

Hello @adambullmer, I'm having a similar issue where my background.js code is not running. I have the default content (generated by your extension) in there, so I was expecting the content script to log a message in the web page console, and the background script to log a message to the background console. Neither of these is happening.

Looking at the conversation above, it seems like I need to add some config to get it working, but I don't have enough experience to know what to add or where to add it.

Can you clarify the steps required to get background and content scripts working with the out-of-the-box template?

from vue-cli-plugin-browser-extension.

adambullmer avatar adambullmer commented on August 15, 2024

I think I finally stumbled on the root cause of content scripts and background scripts not executing, and should be released in 0.23.1. It looks like vue added in some optimizations in development mode, but only if your project were using a more recent version of vue-cli-service, and would explain why this was a little harder to track down.

@JasonLearmouth concerning your troubles, I think there is a bug in the scaffolding where the incorrect listener is being applied on the background file when also scaffolding with a popup (the default 2 options). This should be fixed in 0.23.2. Depending on how much work you've put into your project I may recommend just rescaffolding with vue invoke browser-extension once you've updated to the latest version. Otherwise, you can replace the top line of your backgound.js file with this:

browser.runtime.onMessage.addListener(function (request, sender, sendResponse) {

from vue-cli-plugin-browser-extension.

doutatsu avatar doutatsu commented on August 15, 2024

First time building an extension as well and trying to figure out why the default background.js doesn't execute. I read through the thread here, but still not really sure why it's not working 🤔 Any help would be appreciated

from vue-cli-plugin-browser-extension.

Related Issues (20)

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.