简体   繁体   中英

How to write a FireFox UI-less addon without using XUL files

I want to write a FireFox extension which simply loads myJavaScript.js if the user navigates to www.myExampleWebsite.com . Futhermore this page then detects that the plugin is installed and interacts with it (but this is not part of the question). I've heard of a possibility by creating an overlay (XUL), which does then define a script-tag with src="myJavaScript.js" . In this file I check with progress listeners for the current URL. But this way feels kind of awkward.

My Question is now: How can I write a native (no special magic SDK) FF plugin without the need for defining a XUL file, but loading a JS file directly if the user navigates to a certain page (owned by me).

In chrome extensions such JS files can be defined directly in the manifest file by using the content_scripts key and the matches array like:

...

"content_scripts":
[{
    "matches": ["https://*.myExampleWebsite.com/*"],
    "js": ["myJavaScript.js"],
    "run_at": "document_idle"
}]

...

There must be an equivalent in FF for this. I searched and googled for 3 hours without any success.

Thank you in advance.

It's called bootstrap addon. Search my _ff-addon-template files at my gists on github:

https://gist.github.com/search?q=%40Noitidart+addon

You'll probably be interested in: _ff-addon-template-BootstrapWatchHostEventListenerInjectFiles.xpi

which watches sites load then do stuff with them on load. basic bootstrap skeleton: https://gist.github.com/Noitidart/9025999

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM