sblask-webextensions / webextension-simple-form-fill

Enter text into input fields by choosing items from the context menu or using the optional autocomplete. New items can be added through the context menu while having some text selected or by changing the add-ons' preferences.

Home Page:https://addons.mozilla.org/firefox/addon/simple-form-fill/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inject the autocomplete before page has loaded

vladnero opened this issue · comments

Sebastian, my friend! You said: "Nothing much I can do, if the page hasn't loaded yet, I can't inject the autocomplete.".
You can add:

"run_at": "document_start"

in "content_scripts".

See description here: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/content_scripts

Tried that, doesn't change anything...

How does it help? If you now how to fix the problem, feel free to send a pull request!

If you really want to run some script before the rest, you have to run it inline:

var actualCode = // Content of scripts/inpage.js here;

var s = document.createElement('script');
s.textContent = actualCode;
(document.head || document.documentElement).appendChild(s);
s.remove();

Ideally, your build script would read scripts/inpage.js, serialize it to a string and put it in the actualCode variable. But if inpage.js is just a few lines of code, then the above can be used.