Improve caller id
This commit is contained in:
parent
44628074c0
commit
0ac9f4d4ae
@ -3,7 +3,7 @@
|
||||
// @author Daniel Triendl
|
||||
// @namespace http://cp-solutions.at
|
||||
// @copyright Copyright 2020 CP Solutions GmbH
|
||||
// @version 3
|
||||
// @version 4
|
||||
// @grant GM.xmlHttpRequest
|
||||
// @grant GM.notification
|
||||
// @include https://192.168.0.154:5001/webclient*
|
||||
@ -231,15 +231,26 @@ const tapi = {
|
||||
},
|
||||
|
||||
showCallNotification: (element) => {
|
||||
var number = element.textContent;
|
||||
var rx = /\+([0-9]+)/
|
||||
var number = element.dataset.id;
|
||||
console.log('TAPI call notification', number);
|
||||
var rx = /(\+?[0-9]+)/;
|
||||
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({
|
||||
method: 'GET',
|
||||
url: 'http://cpatapi.cpsrvweb2016.cp-austria.at/callerid/' + encodeURIComponent(number),
|
||||
onload: function (response) {
|
||||
console.log('TAPI Search response', response);
|
||||
console.log('TAPI callerid response', response);
|
||||
var callerId = JSON.parse(response.responseText);
|
||||
var notification = {
|
||||
text: number
|
||||
@ -254,4 +265,4 @@ const tapi = {
|
||||
};
|
||||
|
||||
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