0

I have an inject.js that executes as soon as my Extension's icon is clicked.

It's invoked with:

chrome.tabs.executeScript({file: 'js/inject.js'}, () => {
    // We don't need to inject code everwhere
    // for example on chrome:// URIs so we just
    // catch the error and log it as a warning.
    if (chrome.runtime.lastError) {
      console.warn(chrome.runtime.lastError.message);
    }
  });

It's making an API call:

     chrome.storage.sync.get(['atsmap'], function(result) {
if (result.atsmap) {
        let requestObj2 = {
            ID: result.atsmap
        }
       $.get('https://myURL', requestObj2, (data2, status2) => {
           console.log(data2);
        })
    }
     });

Because the options.html page (which includes a reference to jquery) hasn't rendered at this point, jQuery is undefined:

Error in response to storage.get: ReferenceError: $ is not defined

Is there a way to load jquery.min.js before the inject.js gets called?

superblowncolon
  • 183
  • 1
  • 1
  • 15

0 Answers0