use simple/plain javascript, seems first much harder but getting used
to in short time actually far easier
https://developer.chrome.com/extensions/devguide
On 2/16/19, Aaron Gray <
aaron...@gmail.com> wrote:
> Does anyone have an example page/tabs based chrome extension that uses
> jQuery please ?
>
> I am having problems getting jQuery to work in a tab based html page
> extension.
>
> I have tried stuff from Stack Overflow but none of their fixes seem to
> work.
>
> background.js
> ~~~~~~~~~~~
> chrome.browserAction.onClicked.addListener(function(tab) {
> chrome.tabs.create({'url': chrome.extension.getURL('page.html')},
> function(tab) {
> // Tab opened.
> chrome.tabs.executeScript(null, { file: "jquery.min.js" }, function() {
> chrome.tabs.executeScript(null, { file: "content.js" });
> });
> });
> });
>
> Before adding the
>
> chrome.tabs.executeScript(null, { file: "jquery.min.js" }, function()
> { .... });
>
> as suggested by Stack Overflow "articles" I was getting the error :-
>
> Uncaught ReferenceError: $ is not defined
> <
https://stackoverflow.com/questions/30750125/chrome-extensions-uncaught-referenceerror-is-not-defined>
>
> As soon as I do the :-
>
> chrome.tabs.executeScript(null, { file: "jquery.min.js" }, function()
> {...});
>
> line I am getting the following error occur :-
>
> Unchecked runtime.lastError: Cannot access contents
> of url "chrome-extension://hpnbnfioohjamjenbkigleidhpokegcd/page.html".
> Extension manifest must request permission to access this host.
> Context_generated_background_page.html
> Stack Trace
> _generated_background_page.html:0 (anonymous function)
>
> I have put the code on GitHub, so either a fix or a pointer to code that
> works would be well appreciated.
>
>
https://github.com/AaronNGray/ChromeExtensionPageTest
>
> Many thanks in advance,
>
> Aaron
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Chromium Extensions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
chromium-extens...@chromium.org.
> To post to this group, send email to
chromium-...@chromium.org.
> Visit this group at
>
https://groups.google.com/a/chromium.org/group/chromium-extensions/.
> To view this discussion on the web visit
>
https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/548e28a6-61bb-408c-ada4-d66fa4af9df2%40chromium.org.
> For more options, visit
https://groups.google.com/a/chromium.org/d/optout.
>