How to play audio on Chrome extension? -


i writing mini addon chrome. in addon, have inserted code play audio ajax success. doesn't work websites use https, works fine on websites use http. can me edit it.

manifest.json

enter image description here

mystyle.js

enter image description here

for full resolution of images:

http://i.stack.imgur.com/x8f5q.png

http://i.stack.imgur.com/7bx5i.png

at first glance, there 2 issues code:

  1. you shouldn't put chrome.tabs.getselected , chrome.browseraction in mystyle.js. mystyle.js content script, can access limited chrome api.

    however, content scripts have limitations. cannot:

    • use chrome.* apis, exception of:

      • extension ( geturl , inincognitocontext , lasterror , onrequest , sendrequest )
      • i18n
      • runtime ( connect , getmanifest , geturl , id , onconnect , onmessage , sendmessage )
      • storage
    • use variables or functions defined extension's pages

    • use variables or functions defined web pages or other content scripts
  2. you can't send http request https web page, since it's restricted sop , it's browser behavior. solve this, should move http request logic background page , add server url permissions, see following answer more info.

    chrome extension - disable blocking of mixed content


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -