Zaheer
Zaheer

Reputation: 2872

How to programmatically insert a plugin into a web page in Chrome content script?

I am trying to insert a plugin I created into a page using a content script in a Google Chrome extension. According to the documentation: "If your plugin is "public", you can even use a content script to programmatically insert your plugin into a web page." http://code.google.com/chrome/extensions/npapi.html

Unfortunately the examples they give do not inject a plugin programmatically. In the 'background.html' file I embed the plugin using:

and then I can get the plugin by simply calling: document.getElementById('myPlugin')

How do I do this in a javascript content script?

Upvotes: 1

Views: 2009

Answers (1)

Darin
Darin

Reputation: 2121

They mean you need to use the content script to insert the embed tag and information: (psuedo code)

function addIt(){
  myEmbed = document.createElement('embed');
  myEmbed.attributes(add your attributes so easy with jquery);
  document.getElementByTagName('head')[0].append('myEmbed');
}

Upvotes: 1

Related Questions