Improve caller id
This commit is contained in:
parent
44628074c0
commit
0ac9f4d4ae
@ -3,7 +3,7 @@
|
|||||||
// @author Daniel Triendl
|
// @author Daniel Triendl
|
||||||
// @namespace http://cp-solutions.at
|
// @namespace http://cp-solutions.at
|
||||||
// @copyright Copyright 2020 CP Solutions GmbH
|
// @copyright Copyright 2020 CP Solutions GmbH
|
||||||
// @version 3
|
// @version 4
|
||||||
// @grant GM.xmlHttpRequest
|
// @grant GM.xmlHttpRequest
|
||||||
// @grant GM.notification
|
// @grant GM.notification
|
||||||
// @include https://192.168.0.154:5001/webclient*
|
// @include https://192.168.0.154:5001/webclient*
|
||||||
@ -231,15 +231,26 @@ const tapi = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
showCallNotification: (element) => {
|
showCallNotification: (element) => {
|
||||||
var number = element.textContent;
|
var number = element.dataset.id;
|
||||||
var rx = /\+([0-9]+)/
|
console.log('TAPI call notification', number);
|
||||||
|
var rx = /(\+?[0-9]+)/;
|
||||||
var match = rx.exec(number);
|
var match = rx.exec(number);
|
||||||
number = '00' + match[1];
|
if (!match) {
|
||||||
|
console.log('TAPI callerid no number found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
number = match[1];
|
||||||
|
|
||||||
|
if (number.startsWith('+')) {
|
||||||
|
number = number.replace('+', '00');
|
||||||
|
}
|
||||||
|
console.log('TAPI searching callerid for', number);
|
||||||
GM.xmlHttpRequest({
|
GM.xmlHttpRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: 'http://cpatapi.cpsrvweb2016.cp-austria.at/callerid/' + encodeURIComponent(number),
|
url: 'http://cpatapi.cpsrvweb2016.cp-austria.at/callerid/' + encodeURIComponent(number),
|
||||||
onload: function (response) {
|
onload: function (response) {
|
||||||
console.log('TAPI Search response', response);
|
console.log('TAPI callerid response', response);
|
||||||
var callerId = JSON.parse(response.responseText);
|
var callerId = JSON.parse(response.responseText);
|
||||||
var notification = {
|
var notification = {
|
||||||
text: number
|
text: number
|
||||||
@ -254,4 +265,4 @@ const tapi = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
waitForKeyElements('div.nav-search', tapi.createSearchBox, true);
|
waitForKeyElements('div.nav-search', tapi.createSearchBox, true);
|
||||||
waitForKeyElements('.toasterName', tapi.showCallNotification, false);
|
waitForKeyElements('call-view', tapi.showCallNotification, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user