Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger/invoke a Chrome extension from a web page

For the project I'm currently working on, I need to know if it is possible to invoke a Chrome extension.

I.e., clicking on a button (or a link) on my page would call the "Read It" extension, something like that.

like image 544
ksol Avatar asked Jan 03 '12 13:01

ksol


People also ask

How do I automatically add extensions to Chrome?

Go to the app or extension that you want to automatically install. Under Installation policy, choose Force install or Force install + pin. Click Save.


1 Answers

You can inject your content-script to every page (register it in extension manifest) and alter the page html to add your button or a with your custom id.

The execution environment example explains it pretty good how you will trigger an event from the page to your content script. After you manage the trigger you can do anything you want as the extension logic.

Also keep in mind that this will require your extension's content-script to be injected to every page the user visits. It is not possible to actually trigger the execution of your content-script from the page if thats what you were asking.

like image 67
osoner Avatar answered Sep 21 '22 22:09

osoner