Safe Haskell | None |
---|
A module for working with Firefox profiles. Firefox profiles are manipulated in pure code and then "prepared" for network transmission.
- data FirefoxProfile = FirefoxProfile {}
- data PreparedFirefoxProfile
- data FirefoxPref
- = PrefInteger !Integer
- | PrefDouble !Double
- | PrefString !Text
- | PrefBool !Bool
- class ToFirefox a where
- toFirefox :: a -> FirefoxPref
- addPref :: ToFirefox a => Text -> a -> FirefoxProfile -> FirefoxProfile
- getPref :: Text -> FirefoxProfile -> Maybe FirefoxPref
- deletePref :: Text -> FirefoxProfile -> FirefoxProfile
- addExtension :: FilePath -> FirefoxProfile -> FirefoxProfile
- deleteExtension :: FilePath -> FirefoxProfile -> FirefoxProfile
- loadProfile :: MonadIO m => FilePath -> m FirefoxProfile
- prepareProfile :: MonadIO m => FirefoxProfile -> m PreparedFirefoxProfile
- prepareTempProfile :: MonadIO m => (FirefoxProfile -> FirefoxProfile) -> m PreparedFirefoxProfile
- prepareLoadedProfile :: MonadIO m => FilePath -> (FirefoxProfile -> FirefoxProfile) -> m PreparedFirefoxProfile
Profiles
data FirefoxProfile Source
A pure representation of a FirefoxProfile. This structure allows you to
construct and manipulate Firefox profiles in pure code, deferring execution
of IO operations until the profile is "prepared" using either
prepareProfile
or one of the wrapper functions prepareTempProfile
and
prepareLoadedProfile
.
FirefoxProfile | |
|
data PreparedFirefoxProfile Source
Represents a Firefox profile that has been prepared for network transmission. The profile cannot be modified in this form.
Preferences
data FirefoxPref Source
A Firefox preference. This is the subset of JSON values that excludes arrays and objects.
A typeclass to convert types to Firefox preference values
toFirefox :: a -> FirefoxPrefSource
addPref :: ToFirefox a => Text -> a -> FirefoxProfile -> FirefoxProfileSource
Add a new preference entry to a profile, overwriting any existing entry with the same key.
getPref :: Text -> FirefoxProfile -> Maybe FirefoxPrefSource
Retrieve a preference from a profile by key name.
deletePref :: Text -> FirefoxProfile -> FirefoxProfileSource
Delete an existing preference entry from a profile. This operation is silent if the preference wasn't found.
Extensions
addExtension :: FilePath -> FirefoxProfile -> FirefoxProfileSource
Add a new extension to the profile. The file path should refer to an .xpi file or an extension directory. This operation has no effect if the same extension has already been added to this profile.
deleteExtension :: FilePath -> FirefoxProfile -> FirefoxProfileSource
Delete an existing extension from the profile. The file path should refer to an .xpi file or an extension directory. This operation has no effect if the extension was never added to the profile.
Loading and preparing profiles
loadProfile :: MonadIO m => FilePath -> m FirefoxProfileSource
Load an existing profile from the file system. Any prepared changes made to the FirefoxProfile will have no effect to the profile on disk.
prepareProfile :: MonadIO m => FirefoxProfile -> m PreparedFirefoxProfileSource
Prepare a FirefoxProfile for network transmission.
Internally, this function constructs a Firefox profile within a temp directory, archives it as a zip file, and then base64 encodes the zipped data. The temporary directory is deleted afterwards
prepareTempProfile :: MonadIO m => (FirefoxProfile -> FirefoxProfile) -> m PreparedFirefoxProfileSource
Apply a function on an automatically generated default profile, and prepare the result. The FirefoxProfile passed to the handler function is the same one used by sessions when no Firefox profile is specified
prepareLoadedProfile :: MonadIO m => FilePath -> (FirefoxProfile -> FirefoxProfile) -> m PreparedFirefoxProfileSource
Convenience function to load an existing Firefox profile from disk, apply a handler function, and then prepare the result for network transmission.