Appearance
Global Variables
Here are some global variables you can use when writing a custom script for the extension
$helper.getWorkflows
$helper.getWorkflows(routineId?: string): Promise<Routine | undefined>
Get a specific routine or all the routines of the extension.
Parameters:
routineId: the id of the routine
Examples
js
// Get all routines
$helper.getWorkflows().then((routines) => {
console.log(routines);
});
// Get a specific routine
$helper.getWorkflows('routine-id').then((routine) => {
console.log(routine);
});// Get all routines
$helper.getWorkflows().then((routines) => {
console.log(routines);
});
// Get a specific routine
$helper.getWorkflows('routine-id').then((routine) => {
console.log(routine);
});$helper.executeRoutine
$helper.executeRoutine(routineData: Routine | string, options?: Options): void
To execute a routine.
Parameters:
routineData: the routine data or the id of the routine to executeoptions: the options for the routine execution
Examples
js
(async () => {
// Using routine id
$helper.executeRoutine('routine-id');
// Using routine object
const routine = await $helper.getRoutine('routine-id');
$helper.executeRoutine(routine);
// Passing variables and global data options for the routine
const globalData = [{ key: 'value', name: 'John Doe' }];
const variables = { variableName: 'Variable value', number: 10 };
$helper.executeRoutine('routine-id', {
data: {
variables,
globalData,
}
});
})()(async () => {
// Using routine id
$helper.executeRoutine('routine-id');
// Using routine object
const routine = await $helper.getRoutine('routine-id');
$helper.executeRoutine(routine);
// Passing variables and global data options for the routine
const globalData = [{ key: 'value', name: 'John Doe' }];
const variables = { variableName: 'Variable value', number: 10 };
$helper.executeRoutine('routine-id', {
data: {
variables,
globalData,
}
});
})()$helper.storage.variables
Access or manipulate the variables stored in the storage.
Examples
js
(async () => {
// Get all variables
const variables = await $helper.storage.variables.get(null);
console.log(variables) // { name: 'John Doe', email: '[email protected]', username: 'john_doe' }
// Get a specific variable
const variables = await $helper.storage.variables.get('name');
console.log(variables) // { name: 'John Doe' }
// Get multiple variables
const variables = await $helper.storage.variables.get(['name', 'email']);
console.log(variables) // { name: 'John Doe', email: '[email protected]' }
// Add or update variables
await $helper.storage.variables.set({
country: 'US',
name: 'Jonathan Doe',
email: '[email protected]',
});
// Delete a variable
await $helper.storage.variables.delete('name');
// Delete multiple variables
await $helper.storage.variables.delete(['name', 'email']);
// Delete all variables
$helper.storage.variables.clear();
})();(async () => {
// Get all variables
const variables = await $helper.storage.variables.get(null);
console.log(variables) // { name: 'John Doe', email: '[email protected]', username: 'john_doe' }
// Get a specific variable
const variables = await $helper.storage.variables.get('name');
console.log(variables) // { name: 'John Doe' }
// Get multiple variables
const variables = await $helper.storage.variables.get(['name', 'email']);
console.log(variables) // { name: 'John Doe', email: '[email protected]' }
// Add or update variables
await $helper.storage.variables.set({
country: 'US',
name: 'Jonathan Doe',
email: '[email protected]',
});
// Delete a variable
await $helper.storage.variables.delete('name');
// Delete multiple variables
await $helper.storage.variables.delete(['name', 'email']);
// Delete all variables
$helper.storage.variables.clear();
})();chrome
To access the browser API. See all the available APIs on Chrome Developer documentation
Examples
js
(async () => {
// Get all tabs
const tabs = await chrome.tabs.query({});
// Get the current active tab
const tab = await chrome.tabs.query({ active: true, currentWindow: true });
})();(async () => {
// Get all tabs
const tabs = await chrome.tabs.query({});
// Get the current active tab
const tab = await chrome.tabs.query({ active: true, currentWindow: true });
})();
Brainwrite Swift Docs