0

So I have a chrome extension where I am trying to use Afterglow player to play a video that is already on the page. As I understand, the player works by looking through the html once the readystate is complete and takes control of the video or link elements that have the class "afterglow" and changes their elements with javascript. Since I am new to Chrome extensions, I am having trouble figuring out how I should include this library. My manifest page looks like this currently (with website and name changed)

{
  "name": "CHANGE THIS : Extension boilerplate",
  "version": "0.0.1",
  "manifest_version": 2,
  "description": "This extension was created with the awesome extensionizr.com",
  "homepage_url": "http://extensionizr.com",
  "icons": {
    "16": "icons/icon16.png",
    "48": "icons/icon48.png",
    "128": "icons/icon128.png"
  },
  "default_locale": "en",
  "browser_action": {
    "default_icon": "icons/icon19.png",
    "default_title": "browser action demo",
    "default_popup": "src/browser_action/browser_action.html"
  },
  "permissions": [
    "http://www.google.com/*"
  ],
  "content_scripts": [
    {
      "matches": [
        "https://www.google.com/*"
      ],
      "css": [
        "src/inject/inject.css"
      ]
    },
    {
      "matches": [
        "http:/www.google.com/*"
      ],
      "js": [
        "src/afterglow/afterglow.min.js", "src/inject/inject.js" 
      ]
    }
  ]
}

but when I try to reference afterglow in the way described in the API I get

Uncaught ReferenceError: afterglow is not defined           inject.js

or, if I create a script element and inject the code in that way I get

Uncaught ReferenceError: afterglow is not defined           VM####

How can I include it in my project so that the html can have class="afterglow" and I can use the afterglow object in my code?

Just so there is no confusion, the video already works fine. That is not the issue. The only issue is getting it in the afterglow player.

  • Most probably, it should be [injected as a page-level script](http://stackoverflow.com/a/9517879/3959875). And to control/customize it you'll have to inject your code too. – wOxxOm Aug 03 '16 at 05:20
  • I think so, too. Probably, the chrome extension you built works in a sandbox (I don't know much about how chrome extensions work). So there is no javascript object `afterglow` on the root level. It's probably something like `chrome.extensions.myextension.afterglow` or some sort of accessing structure... – mvmoay Aug 23 '16 at 14:47

0 Answers0