| 1 | package Waterfox::Marionette::Profilescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/; |
| 2 | |
| 3 | use strictscip-perl cpan Firefox-Marionette 1.70 strict/; |
| 4 | use warningsscip-perl cpan Firefox-Marionette 1.70 warnings/; |
| 5 | use Englishscip-perl cpan Firefox-Marionette 1.70 English/ qw( -no_match_vars ); |
| 6 | use File::Specscip-perl cpan Firefox-Marionette 1.70 File/Spec/(); |
| 7 | use parentscip-perl cpan Firefox-Marionette 1.70 parent/ qw(Firefox::Marionette::Profile); |
| 8 | |
| 9 | BEGIN { |
| 10 | if ( $OSNAMEscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/$OSNAME. eq 'MSWin32' ) { |
| 11 | requirescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/require(). Win32; |
| 12 | } |
| 13 | } |
| 14 | our $VERSIONscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/$VERSION. = '1.70'; |
| 15 | |
| 16 | sub profile_ini_directoryscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/profile_ini_directory(). { |
| 17 | my ($class) = @_scip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/`@_`.; |
| 18 | my $profile_ini_directory; |
| 19 | if ( $OSNAMEscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/$OSNAME. eq 'darwin' ) { |
| 20 | my $home_directory = |
| 21 | ( getpwuidscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/getpwuid(). $EFFECTIVE_USER_IDscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/$EFFECTIVE_USER_ID. ) |
| 22 | [ $class->SUPER::_GETPWUID_DIR_INDEXscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/`SUPER::_GETPWUID_DIR_INDEX`().() ]; |
| 23 | definedscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/defined(). $home_directory |
| 24 | or Firefox::Marionette::Exception->throwscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Exception/throw().( |
| 25 | "Failed to execute getpwuid for $OSNAME:$EXTENDED_OS_ERROR"); |
| 26 | $profile_ini_directory = File::Spec->catdirscip-perl cpan Firefox-Marionette 1.70 File/Spec/catdir().( $home_directory, 'Library', |
| 27 | 'Application Support', 'Waterfox' ); |
| 28 | } |
| 29 | elsif ( $OSNAMEscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/$OSNAME. eq 'MSWin32' ) { |
| 30 | $profile_ini_directory = |
| 31 | File::Spec->catdirscip-perl cpan Firefox-Marionette 1.70 File/Spec/catdir().( Win32::GetFolderPathscip-perl cpan Firefox-Marionette 1.70 Win32/GetFolderPath().( Win32::CSIDL_APPDATAscip-perl cpan Firefox-Marionette 1.70 Win32/CSIDL_APPDATA().() ), |
| 32 | 'Waterfox', 'Waterfox' ); |
| 33 | } |
| 34 | elsif ( $OSNAMEscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/$OSNAME. eq 'cygwin' ) { |
| 35 | $profile_ini_directory = |
| 36 | File::Spec->catdirscip-perl cpan Firefox-Marionette 1.70 File/Spec/catdir().( $ENVscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/`%ENV`.{APPDATA}, 'Waterfox', 'Waterfox' ); |
| 37 | } |
| 38 | else { |
| 39 | my $home_directory = |
| 40 | ( getpwuidscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/getpwuid(). $EFFECTIVE_USER_IDscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/$EFFECTIVE_USER_ID. ) |
| 41 | [ $class->SUPER::_GETPWUID_DIR_INDEXscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/`SUPER::_GETPWUID_DIR_INDEX`().() ]; |
| 42 | definedscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/defined(). $home_directory |
| 43 | or Firefox::Marionette::Exception->throwscip-perl cpan Firefox-Marionette 1.70 Firefox/Marionette/Exception/throw().( |
| 44 | "Failed to execute getpwuid for $OSNAME:$EXTENDED_OS_ERROR"); |
| 45 | $profile_ini_directory = |
| 46 | File::Spec->catdirscip-perl cpan Firefox-Marionette 1.70 File/Spec/catdir().( $home_directory, '.waterfox' ); |
| 47 | } |
| 48 | return $profile_ini_directory; |
| 49 | } |
| 50 | |
| 51 | sub newscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/new(). { |
| 52 | my ( $class, %parameters ) = @_scip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/`@_`.; |
| 53 | my $profile = blessscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/bless(). { comments => q[], keys => {} }, $class; |
| 54 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'bookmarks.initialized.pref', 'true', 0 ); |
| 55 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.bookmarks.restore_default_bookmarks', |
| 56 | 'false', 0 ); |
| 57 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.download.useDownloadDir', 'true', 0 ); |
| 58 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.download.folderList', 2, 0 ) |
| 59 | ; # the last folder specified for a download |
| 60 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.places.importBookmarksHTML', 'true', 0 ); |
| 61 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.reader.detectedFirstArticle', 'true', 0 ); |
| 62 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.shell.checkDefaultBrowser', 'false', 0 ); |
| 63 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.showQuitWarning', 'false', 0 ); |
| 64 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.startup.homepage', 'about:blank', 1 ); |
| 65 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.startup.homepage_override.mstone', |
| 66 | 'ignore', 1 ); |
| 67 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.startup.page', '0', 0 ); |
| 68 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.tabs.warnOnClose', 'false', 0 ); |
| 69 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'browser.warnOnQuit', 'false', 0 ); |
| 70 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'devtools.jsonview.enabled', 'false', 0 ); |
| 71 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'devtools.netmonitor.persistlog', 'true', 0 ); |
| 72 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'devtools.toolbox.host', 'window', 1 ); |
| 73 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'dom.disable_open_click_delay', 0, 0 ); |
| 74 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'extensions.installDistroAddons', 'false', 0 ); |
| 75 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'focusmanager.testmode', 'true', 0 ); |
| 76 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'marionette.port', $class->SUPER::ANY_PORTscip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/`SUPER::ANY_PORT`().() ); |
| 77 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'network.http.prompt-temp-redirect', 'false', 0 ); |
| 78 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'network.http.request.max-start-delay', '0', 0 ); |
| 79 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'security.osclientcerts.autoload', 'true', 0 ); |
| 80 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'signon.autofillForms', 'false', 0 ); |
| 81 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'signon.rememberSignons', 'false', 0 ); |
| 82 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'startup.homepage_welcome_url', 'about:blank', 1 ); |
| 83 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'startup.homepage_welcome_url.additional', |
| 84 | 'about:blank', 1 ); |
| 85 | |
| 86 | if ( !$parameters{chatty} ) { |
| 87 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'app.update.auto', 'false', 0 ); |
| 88 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'app.update.staging.enabled', 'false', 0 ); |
| 89 | $profile->set_valuescip-perl cpan Firefox-Marionette 1.70 Waterfox/Marionette/Profile/set_value().( 'app.update.checkInstallTime', 'false', 0 ); |
| 90 | } |
| 91 | |
| 92 | return $profile; |
| 93 | } |
| 94 | |
| 95 | 1; # Magic true value required at end of module |
| 96 | __END__ |
| 97 | |
| 98 | =head1 NAME |
| 99 | |
| 100 | Waterfox::Marionette::Profile - Represents a prefs.js Waterfox Profile |
| 101 | |
| 102 | =head1 VERSION |
| 103 | |
| 104 | Version 1.70 |
| 105 | |
| 106 | =head1 SYNOPSIS |
| 107 | |
| 108 | use Waterfox::Marionette(); |
| 109 | use v5.10; |
| 110 | |
| 111 | my $profile = Waterfox::Marionette::Profile->new(); |
| 112 | |
| 113 | $profile->set_value('browser.startup.homepage', 'https://duckduckgo.com'); |
| 114 | |
| 115 | my $firefox = Waterfox::Marionette->new(profile => $profile); |
| 116 | |
| 117 | $firefox->quit(); |
| 118 | |
| 119 | foreach my $profile_name (Waterfox::Marionette::Profile->names()) { |
| 120 | # start firefox using a specific existing profile |
| 121 | $firefox = Waterfox::Marionette->new(profile_name => $profile_name); |
| 122 | $firefox->quit(); |
| 123 | |
| 124 | # OR start a new browser with a copy of a specific existing profile |
| 125 | |
| 126 | $profile = Waterfox::Marionette::Profile->existing($profile_name); |
| 127 | $firefox = Waterox::Marionette->new(profile => $profile); |
| 128 | $firefox->quit(); |
| 129 | } |
| 130 | |
| 131 | =head1 DESCRIPTION |
| 132 | |
| 133 | This module handles the implementation of a C<prefs.js> Waterfox Profile. This module inherits from L<Firefox::Marionette::Profile|Firefox::Marionette::Profile>. |
| 134 | |
| 135 | =head1 SUBROUTINES/METHODS |
| 136 | |
| 137 | For a full list of methods available, see L<Firefox::Marionette::Profile|Firefox::Marionette::Profile#SUBROUTINES/METHODS> |
| 138 | |
| 139 | =head2 new |
| 140 | |
| 141 | returns a new L<profile|Waterfox::Marionette::Profile>. |
| 142 | |
| 143 | =head2 profile_ini_directory |
| 144 | |
| 145 | returns the base directory for profiles. |
| 146 | |
| 147 | =head1 DIAGNOSTICS |
| 148 | |
| 149 | See L<Firefox::Marionette::Profile|Firefox::Marionette::Profile>. |
| 150 | |
| 151 | =head1 CONFIGURATION AND ENVIRONMENT |
| 152 | |
| 153 | Waterfox::Marionette::Profile requires no configuration files or environment variables. |
| 154 | |
| 155 | =head1 DEPENDENCIES |
| 156 | |
| 157 | Waterfox::Marionette::Profile requires no non-core Perl modules |
| 158 | |
| 159 | =head1 INCOMPATIBILITIES |
| 160 | |
| 161 | None reported. |
| 162 | |
| 163 | =head1 BUGS AND LIMITATIONS |
| 164 | |
| 165 | To report a bug, or view the current list of bugs, please visit L<https://github.com/david-dick/firefox-marionette/issues> |
| 166 | |
| 167 | =head1 AUTHOR |
| 168 | |
| 169 | David Dick C<< <[email protected]> >> |
| 170 | |
| 171 | =head1 LICENSE AND COPYRIGHT |
| 172 | |
| 173 | Copyright (c) 2024, David Dick C<< <[email protected]> >>. All rights reserved. |
| 174 | |
| 175 | This module is free software; you can redistribute it and/or |
| 176 | modify it under the same terms as Perl itself. See L<perlartistic/perlartistic>. |
| 177 | |
| 178 | =head1 DISCLAIMER OF WARRANTY |
| 179 | |
| 180 | BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
| 181 | FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
| 182 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
| 183 | PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
| 184 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 185 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
| 186 | ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
| 187 | YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
| 188 | NECESSARY SERVICING, REPAIR, OR CORRECTION. |
| 189 | |
| 190 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
| 191 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
| 192 | REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
| 193 | LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
| 194 | OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
| 195 | THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
| 196 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
| 197 | FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
| 198 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
| 199 | SUCH DAMAGES. |