extension-api-compilation
Version:
Cross browser extension api
39 lines (35 loc) • 977 B
JavaScript
import Tabs from './tabs';
export default class MozillaTabs extends Tabs {
/**
* Send message to specified object
* @param tabId {Number} id of the tab
* @param msg {Object} Object to send the message to tub
* @returns {Promise}
*/
sendMessage(tabId, msg) {
return browser.tabs.sendMessage(tabId, msg);
}
/**
* Change the tab's location
* @param tabId {Number} Id of the tab
* @param url {String} Url to change page location
*/
update(tabId, url) {
browser.tabs.update(tabId, {url: url});
}
/**
* Executes js code on the specified tab
* @param tabId {Number} id of the tab
* @param code {String} Code to execute on the page
*/
executeScript(tabId, code) {
browser.tabs.executeScript(tabId, {code: code});
}
/**
* Returns currently active tab
* @returns {Promise}
*/
getActive() {
return browser.tabs.query({active: true, currentWindow: true});
}
}