App::FirefoxMultiAccountContainersUtils - Utilities related to Firefox Multi-Account Containers add-on
This document describes version 0.015 of App::FirefoxMultiAccountContainersUtils (from Perl distribution App-FirefoxMultiAccountContainersUtils), released on 2022-10-04.
This distribution includes several utilities related to Firefox multi-account containers addon:
firefox-container
firefox-mua-list-containers
firefox-mua-modify-containers
firefox-mua-sort-containers
open-firefox-container
About the add-on: https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/.
Usage:
firefox_mua_list_containers(%args) -> [$status_code, $reason, $payload, \%result_meta]
List Firefox Multi-Account Containers add-on's containers.
This function is not exported.
Arguments ('*' denotes required arguments):
profile* => firefox::local_profile_name
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.
Return value: (any)
firefox_mua_modify_containers(%args) -> [$status_code, $reason, $payload, \%result_meta]
Modify (and delete) Firefox Multi-Account Containers add-on's containers with Perl code.
Examples:
Delete all containers matching some conditions (remove -n to actually delete it):
firefox_mua_modify_containers( profile => "myprofile", code => "return 0 if \$_->{icon} eq \"cart\" || \$_->{name} =~ /temp/i; \$_" );
Delete all containers (remove -n to actually delete it):
firefox_mua_modify_containers(profile => "myprofile", code => 0);
Change all icons to "dollar" and all colors to "red":
firefox_mua_modify_containers( profile => "myprofile", code => "\$_->{icon} = \"dollar\"; \$_->{color} = \"red\"; \$_" );
This utility lets you modify the identity records in containers.json file using Perl code. The Perl code is called for every container (record). It is given the record hash in $_ and is supposed to modify and return the modified the record. It can also choose to return false to instruct deleting the record.
containers.json
$_
This function supports dry-run operation.
code* => code|str
Special arguments:
-dry_run => bool
Pass -dry_run=>1 to enable simulation mode.
firefox_mua_sort_containers(%args) -> [$status_code, $reason, $payload, \%result_meta]
Sort Firefox Multi-Account Containers add-on's containers.
This utility was written when the Firefox Multi-Account Containers add-on does not provide a way to reorder the containers. Now it does; you can click Manage Containers then use the hamburger button to drag the containers up and down to reorder.
However, this utility is still useful particularly when you have lots of containers and want to sort it in some way. This utility provides a flexible sorting mechanism via using <pm:Sort:Sub> modules. For example:
% firefox-mua-sort-containers MYPROFILE % firefox-mua-sort-containers MYPROFILE -S by_example -A example=foo,bar,baz,qux
will first sort your containers asciibetically, then put specific containers that you use often (foo, bar, baz, qux) at the top.
foo
bar
baz
qux
sort_args => array[str]
Arguments to pass to the Sort::Sub::* routine.
sort_sub => sortsub::spec
Name of a Sort::Sub::* module (without the prefix).
open_firefox_container(%args) -> [$status_code, $reason, $payload, \%result_meta]
CLI to open URL in a new Firefox tab, in a specific multi-account container.
Open two URLs in a container called "mycontainer":
open_firefox_container( container => "mycontainer", urls => ["www.example.com", "www.example.com/url2"] );
If URL is not specified, will open a blank tab:
open_firefox_container(container => "mycontainer");
This utility opens a new firefox tab in a specific multi-account container. This requires the Firefox Multi-Account Containers add-on, as well as another add-on called "Open external links in a container", https://addons.mozilla.org/en-US/firefox/addon/open-url-in-container/.
The way it works, because add-ons currently do not have hooks to the CLI, is via a custom protocol handler. For example, if you want to open http://www.example.com/ in a container called mycontainer, you ask Firefox to open this URL:
mycontainer
ext+container:name=mycontainer&url=http://www.example.com/
Ref: https://github.com/mozilla/multi-account-containers/issues/365
container* => str
profile => firefox::local_profile_name
urls => array[str]
Please visit the project's homepage at https://metacpan.org/release/App-FirefoxMultiAccountContainersUtils.
Source repository is at https://github.com/perlancar/perl-App-FirefoxMultiAccountContainersUtils.
"Open external links in a container" add-on, https://addons.mozilla.org/en-US/firefox/addon/open-url-in-container/ (repo at https://github.com/honsiorovskyi/open-url-in-container/). The add-on also comes with a bash launcher script: https://github.com/honsiorovskyi/open-url-in-container/blob/master/bin/launcher.sh. This firefox-container Perl script is a slightly enhanced version of that launcher script.
Some other CLI utilities related to Firefox: App::FirefoxUtils, App::DumpFirefoxHistory.
perlancar <perlancar@cpan.org>
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.
This software is copyright (c) 2022, 2020 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-FirefoxMultiAccountContainersUtils
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
To install App::FirefoxMultiAccountContainersUtils, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::FirefoxMultiAccountContainersUtils
CPAN shell
perl -MCPAN -e shell install App::FirefoxMultiAccountContainersUtils
For more information on module installation, please visit the detailed CPAN module installation guide.