The only way to do it right, at least for now, is to buy VoipTools package. However, I found this solution is way too expensive, especially knowing that I need only one tool from the package (other features offered by VoipTools are totally useless in my case). Even though my office would probably pay for the license if it was one-time payment, but there is only a subscription option.
The current workaround that we have in the office is we intercept the new tab created by 3CX extension. In details:
- you need to find an "integration" settings in 3CX extension and set some valid url in it (you can pass incoming number here),
- grant the permission to deal with Tabs to your own extension,
- create a chrome.tabs.onCreated listener in your background.js and catch all tabs that trying to open your predefined url,
- if there is a tab trying to open your url then this is "incoming call" event created by 3CX, you can apply extra logic to it
JavaScript:
chrome.tabs.onCreated.addListener((tab) => {
const { pendingUrl, id } = tab;
// intercept the tab created by 3CX
if (pendingUrl.match(/ some RegEx here /)) {
// delete the tab
chrome.tabs.remove(id);
//
// execute some extra logic here
//
}
});
The only problem with this solution is "flickering". 3CX extension intentionally makes the new tab active, as a result of this, the user will see a new tab for a moment.