0

I am writing a mini addon for chrome. In the addon, I have inserted a code to play audio where ajax is success. It doesn't work with websites that use https, but works fine on websites that use http. Can you help me edit it.

manifest.json

enter image description here

mystyle.js

enter image description here

For full resolution of the images:

https://i.stack.imgur.com/x8F5Q.png

https://i.stack.imgur.com/7bX5I.png

Termininja
  • 6,620
  • 12
  • 48
  • 49
huudepzai
  • 1
  • 3

1 Answers1

0

At a first glance, there are two issues with your code:

  1. You shouldn't put chrome.tabs.getSelected and chrome.browserAction in mystyle.js. mystyle.js is a content script, which can only access limited chrome api.

    However, content scripts have some limitations. They cannot:

    • Use chrome.* APIs, with the exception of:

      • extension ( getURL , inIncognitoContext , lastError , onRequest , sendRequest )
      • i18n
      • runtime ( connect , getManifest , getURL , id , onConnect , onMessage , sendMessage )
      • storage
    • Use variables or functions defined by their extension's pages

    • Use variables or functions defined by web pages or by other content scripts
  2. You can't send http request from a https web page, since it's restricted by SOP and it's a browser behavior. To solve this, you should move your http request logic to background page and add the server url to permissions, see my following answer for more info.

    Chrome extension - Disable Blocking of Mixed Content

Community
  • 1
  • 1
Haibara Ai
  • 10,703
  • 2
  • 31
  • 47