Constructor
new Profile(options)
Create a Profile
Parameters:
Name | Type | Description |
---|---|---|
options |
module:profile/profile~ProfileOptions |
Methods
static assertValidBrowser(browser)
throw an exception if {browser} is not valid
Parameters:
Name | Type | Description |
---|---|---|
browser |
string |
async static exists(path) → {Promise.<boolean>}
Path of the profile on the file system
Parameters:
Name | Type | Description |
---|---|---|
path |
string | path of the profile |
true is profile exists
async static getChromeExtension() → {Promise.<String>}
Get extension for chrome from url and save it to {cache}
Parameters:
Name | Type | Description |
---|---|---|
params.id |
string | the id of the chrome extension you can also use the {url} param (see examples) |
params.url |
string | the url of the chrome extension (see examples) |
params.name |
string | the name of the extension. Will be used as foldername of the extension, so avoid special characters, especially "/" ! |
params.cache |
string | path of the cache folder where the extension will be stored (created if don't exist) |
params.verbose |
boolean | should the function display debug info ? (download progress bar, etc...) |
- Return a promise of the path of the extension
Example
let extensionPath = await Profile.getChromeExtension({
// This is the url of the extension on google Webstore
url: "https://chrome.google.com/webstore/detail/ublock/epcnnfbjfcgphgdmggkamkmgojdagdnn?hl=en",
name: "ublock",
cache: "./.cache", //default value
verbose: true
});
// You can make it shorter by extracting the extension id from the url:
let extensionPath = await Chrome.getExtension({
// https://..../detail/ublock/{id}?hl=en
id: "epcnnfbjfcgphgdmggkamkmgojdagdnn",
name: "ublock",
verbose: true
});
// You can also put the name before the id like this:
let extensionPath = await Chrome.getExtension({
id: "ublock/epcnnfbjfcgphgdmggkamkmgojdagdnn",
verbose: true
});
static path(browser, name) → {string}
Path of the profile on the file system
Parameters:
Name | Type | Description |
---|---|---|
browser |
'firefox' | 'chromium' | the browser type: |
name |
* | name of the profile |
the path of the profile
async static profile(options) → {Promise.<module:profile/profile~Profile>}
Load a profile or create it if it doesn't exist
Parameters:
Name | Type | Description |
---|---|---|
options |
module:profile/profile~ProfileOptions |
static validBrowser(browser)
Return true if {browser} is a valid browser name
Parameters:
Name | Type | Description |
---|---|---|
browser |
string | The type/name of the browser |
async assertDoesntExists()
Throw an error if the profile exists
async assertExists()
Throw an error if the profile doesnt exist
async clear()
Clear the profile : delete it if exist, then init it
async copy(newName)
copy the profile
Parameters:
Name | Type | Description |
---|---|---|
newName |
string |
async exists() → {Promise.<boolean>}
Return true if profile exists in file system
async init()
Init the profile - ie create a folder for the profile
async rename(newName)
Rename the profile
Parameters:
Name | Type | Description |
---|---|---|
newName |
string |