Click to dial - Firefox Quantum

Anyone have any good click to dial or screen pop addons for the new firefox - I can’t seem to find any that work anymore!

I’m also looking for a firefox extensions that works perfectly with Firefox Quantum, as Asterisk Click2dial. Unfortunally Asterisk Click2dial developer is unreachable :frowning:

I made a plugin for internal use, if I can figure out a way to add a header to the AMI then I will publish it. Essentially I cannot find a way to have a TCP tunnel so I need to use the URL POST method for login / originate however since its ‘cross domain’ I need a way to set the “Access-Control-Allow-Origin” header on the * box to allow saving of the cookie in the ajax request.

My solution now sends the data to a third box (Im using a raspberry PI), which then opens a direct socket to the server to send the originate.

Hey, I have made for a friend a new working Asterisk Click2Dial extension for Firefox Quantum:
https://addons.mozilla.org/en-US/firefox/addon/asterisk-click2dial-webext/

It’s only working currently with AJAM support.

@Syntxerr if you are willing to share your work, I would be please to integrate it to my extension.
I know that currently we have to use some kind of proxy for AMI support.

Let me know of any issues or feature requests !

Looks good - I went through the source last night, I wanna do some testing. An issue I was having was getting the script to communicate when calling it from a tab that was secure as it didnt like a call to an insecure domain (IE asterisk box)… I need to see how this preforms

That’s the thing I send requests from the background script and not from tab script.
I would also love to see your code for AMI support ?

Ooops! I never replied!!!

I have the following on a lite server:

<?php
if (isset($_GET['ext']) && isset($_GET['num'])){
        $ext = $_GET['ext'];
        $num = $_GET['num'];

	$fp = fsockopen("xxx.xxx.xxx.xxx","port",$errno,$errsrt,1);
	if (!$fp) {
	    echo "$errstr ($errno)<br />\n";
	} else {
		fwrite($fp, "ACTION: LOGIN\r\nUSERNAME: <USER>\r\nSECRET: <PASS>\r\nEVENTS: OFF\r\n\r\n");
		
		$action = "ACTION: Originate\r\nChannel: SIP/$ext\r\nExten: $num\r\nPriority: 1\r\nContext: DLPN_DP_AVShop\r\n";
		if (isset($_GET['header']))
			$action .= "Variable: " . $_GET['header'] . "\r\n";
                if (isset($_GET['CID']))
                        $action .= "Callerid: " . $_GET['CID'] . "\r\n";
		$action .= "\r\n";
	echo $action;	
		fwrite($fp, $action);
		fwrite($fp, "ACTION: LOGOFF\r\n\r\n");
	while (!feof($fp)) {
		echo fread($fp, 128);
	}
	fclose($fp);
	}
	} else {
		echo ("error");
	}
?>

My global script:

document.addEventListener('selectionchange', function() {
    var selection = window.getSelection().toString().trim();
    chrome.runtime.sendMessage({
        request: 'updateContextMenu',
        selection: selection
    });
});

My background script:

function dialnumber(info)
	{

	var numDial = info.selectionText.replace(/\D/g,'');


	var additional = "";
	var xhttp = new XMLHttpRequest();

	  xhttp.onreadystatechange = function() {
		if(xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
			console.log(xhttp.responseText);
	  }
	  };

	  if (localStorage.header != "")
	  	additional = "&header=__SIPADDHEADER51=" + localStorage.header;
	  if (localStorage.CID != "")
	  	additional +="&CID=" + localStorage.CID;

	  xhttp.open("GET", "http://10.0.165.124/c2d.php?ext=" + localStorage.extension + "&num=" + numDial + additional, true);
	  xhttp.send();

}

//browser.contextMenus.create({title: chrome.i18n.getMessage("dial_number"), contexts:["selection"], onclick: dialnumber});

// ID to manage the context menu entry
var cmid;
//var cm_clickHandler = function(clickData, tab) {
//    console.log('Selected ' + clickData.selectionText + ' in ' + tab.url);
//};

chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
    if (msg.request === 'updateContextMenu') {
        var type = msg.selection.replace(/\D/g,'');
        if (type == '' || !(type.length >= 10 && type.length <= 11)) {
            // Remove the context menu entry
            if (cmid != null) {
                chrome.contextMenus.remove(cmid);
                cmid = null; // Invalidate entry now to avoid race conditions
            } // else: No contextmenu ID, so nothing to remove
        } else { // Add/update context menu entry
            var options = {
                title: "Dial " + type,
                contexts: ['selection'],
                onclick: dialnumber
            };
            if (cmid != null) {
                chrome.contextMenus.update(cmid, options);
            } else {
                // Create new menu, and remember the ID
                cmid = chrome.contextMenus.create(options);
            }
        }
    }
});