const sendCommand = (target, method, params) => new Promise((resolve, reject) => { chrome.debugger.sendCommand(target, method, params, result => { if (chrome.runtime.lastError) { reject(chrome.runtime.lastError); } else { resolve(result); console.log(method, result); } }); }).catch(err => { console.log(method, err); });