It sounds feasible. However, it's harder to do with the new API
(WebExtensions), which is what we're transitioning to, which doesn't
support profile management. You would probably need to offload most of
the work to an external process, which you can do with the connect
native API:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/Runtime/connectNative
The question becomes: do you need this to be an extension? It seems like
an easier thing to do with a bash script or something like that.
Jorge