I am considering how to convert my addon to a webextension: https://addons.mozilla.org/en-US/firefox/addon/jolla-askbot-unseen-posts/
It includes two page scripts which were originally written to work with this site:
but I coded it so that it would work with any site that used the ‘askbot’ software, such as:
It seemed like a good idea at the time!
The user can specify what askbot sites to target, in simple preferences, by providing the match pattern in a parameter called ‘includes’. For example in my case ‘includes’ is set to:
The main script calls the content script like this:
How can I handle this variable match string in a webextension?
I think I cannot do it with a “content_scripts” key in the manifest: that is a fixed string. So it seems I must use tabs.executeScript() and that requires host permission from the target site (or activeTab permission, but that requires user action). And because the target site(s) are variable it must apply to all_urls. I must code the content scripts to check if the URL is a target and if not do nothing.
I don’t like this solution, it’s inefficient. Is there a cleverer way of calling the content script only on the sites specified in the ‘includes’ parameter?