rustyzone / Supabase-Chrome-Ext-Auth

30 stars 5 forks source link

jQuery for content_scripts issue #5

Open lbshopping opened 1 year ago

lbshopping commented 1 year ago

Hi, When I am using jquery with this code, the plugin doesn't run. It gives a code 3 error.

I've tried adding jQuery through npm and importing it inside content.js like:

const { JSDOM } = require( "jsdom" );
const { window } = new JSDOM( "" );
const $ = require( "jquery" )( window );

into content.js, the plugin runs, but jQuery doesn't run

Any clues would be highly appreciated.

  "content_scripts": [
    {
      "matches": [
        "https://*.website.com/*"
      ],
      "all_frames": true,
      "js": [
        "content.js"
      ]
    }
  ],
  "background": {
    "service_worker": "bg-supa.js",
    "type": "module"
  },
mubaidr commented 1 year ago

Can you please explain what are you trying to achieve here?

lbshopping commented 1 year ago

Can you please explain what are you trying to achieve here?

Want to use jQuery with it

mubaidr commented 1 year ago

Why not just add jquery files to content_scripts?

lbshopping commented 1 year ago

It will not work, so I have to add it using npm or yarn

mubaidr commented 1 year ago

It should work as expected.

"content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*"],
      "js": ["/libs/jquery-3.2.1.min.js"]   ,
      "run_at": "document_end"
    }
  ]

Or if at runtime:

chrome.browserAction.onClicked.addListener(function (tab) {
    chrome.tabs.executeScript({
        file: "/libs/jquery-3.2.1.min.js"
    }, function() {
        chrome.tabs.executeScript({
            file: 'work.js'
        });
    });
});
lbshopping commented 1 year ago

In both cases it's not running, I get the following error:

image image

mubaidr commented 1 year ago

This error is related to backend script.

lbshopping commented 1 year ago

There is no backend script

mubaidr commented 1 year ago

you are trying to load: bg-supa.js. Read the error message, please

lbshopping commented 1 year ago

yes, it's loaded from the manifest.json if you check it and it runs without any problem. But once I add jQuery in any way whether through Yarn, NPM or manually, the problem shows.