function sendMessage(message) {
    //console.log('send message:', message);
    if (navigator.userAgent.toLowerCase().indexOf('chrome') !== -1) {
        //console.log('chrome');
        return new Promise( (resolve, reject) => {
            chrome.runtime.sendMessage(message,{}, (response) => {
                const error = chrome.runtime.lastError;
                if (error) {
                    reject(error)
                }
                resolve(response);
            })
        })
    } else {
        //console.log('firefox');
        return browser.runtime.sendMessage(message);
    }
}

function getCurrent() {
    if (navigator.userAgent.toLowerCase().indexOf('chrome') !== -1) {
        return new Promise( (resolve, reject) => {
            chrome.windows.getCurrent({},(window) => {
                const error = chrome.runtime.lastError;
                if (error) {
                    reject(error)
                }
                resolve(window);
            })
        });
    } else {
        return browser.windows.getCurrent();
    }
}