Skip to content

Commit

Permalink
Tel-Link auf allen Seiten
Browse files Browse the repository at this point in the history
Tel-Link sollte damit jetzt auf allen Seiten funktionieren
  • Loading branch information
Janokisu committed Oct 31, 2022
1 parent 82d2074 commit f6806ca
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 92 deletions.
142 changes: 73 additions & 69 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,82 +583,86 @@ let Listener_SelectionNumber = "";
browser.runtime.onMessage.addListener(function (request, sender, sendResponse){
//console.log("request",request)

if ( request.hasOwnProperty("settings_change") ) {
settings_changed();
}

/*
if ( request.hasOwnProperty("python erreichbar") ) {
CallMonitor_connnect();
}
*/
if( request.hasOwnProperty("callListTransfer") ){
blink_missed("off");
sendResponse({
callList: GL_call_list_popup,
callList_raw: GL_call_list_popup_raw
});
}

if( request.hasOwnProperty("phoneListTransfer") ){
sendResponse({
phoneList: GL_phone_list_popup,
phoneList_raw: GL_phone_list_popup_raw
});
}

if ( request.hasOwnProperty("call_test") ) {
let info = request["call_test"].split(";")
//console.warn(info);
work(info);
}
switch(true){

if ( request.hasOwnProperty("Call_Number") ) {
//Nummer anrufen
callNumber( request["Call_Number"], sendResponse );
callNumber_check = true;
case request.settings_change:
settings_changed();
break;

//wenn nach 3 sek callNumber_check noch true ist, ist alles gut. Anstonsten gabe es probleme
setTimeout(() => {
if(callNumber_check == true){
startGetDialConfig();
}
}, 3000);
}

if( request.hasOwnProperty("HangUp") ){
hangup(sendResponse);
}

if( request.hasOwnProperty("checkCalling") ){
if(Listener_Dial == ""){
/*
case request.python_erreichbar:
CallMonitor_connnect();
break;
*/

case request.callListTransfer:
blink_missed("off");
sendResponse({
"Listener_Dial": ""
callList: GL_call_list_popup,
callList_raw: GL_call_list_popup_raw
});
}
else{
break;

case request.phoneListTransfer:
sendResponse({
"Listener_Dial": Listener_Dial.concat( returnNumberName(Listener_Dial[1]) )
phoneList: GL_phone_list_popup,
phoneList_raw: GL_phone_list_popup_raw
});
}
}

if( request.hasOwnProperty("checkSelectionNumber") ){
sendResponse({
"callSelectionNumber": [Listener_SelectionNumber, returnNumberName(Listener_SelectionNumber)]
});
break;

Listener_SelectionNumber = "";
}

if( request.hasOwnProperty("refresh_phonebook") ){
phoneList_start();
}

if( request.hasOwnProperty("checkPython") ){
sendResponse({
"pythonCheck": GL_PythonListen.isRunning()
});
case request.call_test:
let info = request["call_test"].split(";")
//console.warn(info);
work(info);
break;

case request.Call_Number:
//Nummer anrufen
callNumber( request["Call_Number"], sendResponse );
callNumber_check = true;

//wenn nach 3 sek callNumber_check noch true ist, ist alles gut. Anstonsten gabe es probleme
setTimeout(() => {
if(callNumber_check == true){
startGetDialConfig();
}
}, 3000);
break;

case request.HangUp:
hangup(sendResponse);
break;

case request.checkCalling:
if(Listener_Dial == ""){
sendResponse({
"Listener_Dial": ""
});
}
else{
sendResponse({
"Listener_Dial": Listener_Dial.concat( returnNumberName(Listener_Dial[1]) )
});
}
break;

case request.checkSelectionNumber:
sendResponse({
"callSelectionNumber": [Listener_SelectionNumber, returnNumberName(Listener_SelectionNumber)]
});

Listener_SelectionNumber = "";
break;

case request.refresh_phonebook:
phoneList_start();
break;

case request.checkPython:
sendResponse({
"pythonCheck": GL_PythonListen.isRunning()
});
break;
}
})

Expand Down
4 changes: 2 additions & 2 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ save_button.addEventListener("click", function(){
);
*/

GL_accessAllWebsitesPermission[0] != check_url_Fbox();
GL_accessAllWebsitesPermission[0] = !check_url_Fbox();
GL_accessAllWebsitesPermission[1] = check_tel_link.checked;
accessAllWebsites(-1);

Expand Down Expand Up @@ -768,7 +768,7 @@ function init(x){
change_volume(tmp);

//Rechte für alle Seiten entfernen, wenn es nicht mehr gebruacht wird
GL_accessAllWebsitesPermission[0] != check_url_Fbox();
GL_accessAllWebsitesPermission[0] = !check_url_Fbox();
GL_accessAllWebsitesPermission[1] = check_tel_link.checked;
accessAllWebsites(-1);
}
Expand Down
66 changes: 45 additions & 21 deletions telLink.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,56 @@
function telLinkClick(evt){
let target = evt.target
try{
//try - beim 1. mal gibt es varListen noch nicht. wenn executeScript erneut ausgeführt wird, wird das Skript fortlaufend unten angehängt
browser.runtime.onMessage.removeListener(varListen); //vorherige Listener löschen
}
catch(e){}


controller = new AbortController();

varTelLinkClick = function telLinkClick(evt){

if(target.tagName == "A" && target.protocol == "tel:"){

evt.preventDefault(); //Linkausführung verhindern


let tel = target.href.slice(4).trim().replace(/[^0-9()+*]/g, "");
if(tel != ""){
let x = confirm( browser.i18n.getMessage("pop_askNumberText_Number", [tel]) )
if(x == true){
browser.runtime.sendMessage({
"Call_Number": tel
});
}
evt.preventDefault(); //Linkausführung verhindern


let tel = this.href.replace(/[^0-9()+*]/g, "");
if(tel != ""){
let x = confirm( browser.i18n.getMessage("pop_askNumberText_Number", [tel]) )
if(x == true){
browser.runtime.sendMessage({
"Call_Number": tel
});
}

}

}


browser.runtime.onMessage.addListener(function (request, sender, sendResponse){
varListen = function (request, sender, sendResponse){
//console.log("rec", request)
if( request.hasOwnProperty("telLink_func_destroy") ){
document.removeEventListener("click", telLinkClick);
//document.removeEventListener("click", varTelLinkClick);
controller.abort(); // entfernt alle Listener vom Addon auf der Seite
}
});
}




for(tagName of document.getElementsByTagName("a")){
if(tagName.protocol == "tel:"){
console.log(tagName)

tagName.addEventListener("click", varTelLinkClick, { signal: controller.signal });
}
}

browser.runtime.onMessage.addListener(varListen);









document.removeEventListener("click", telLinkClick); //falls noch alter listerner da war
document.addEventListener("click", telLinkClick);

0 comments on commit f6806ca

Please sign in to comment.