3cx Click2Call

Ein Klick auf tel: und callto: Links soll über den 3cx Webclient einen Anruf starten.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        3cx Click2Call
// @namespace   3cx
// @match       https://*/*
// @grant       none
// @version     1.3
// @author      Jakob Schöttl
// @license MIT
// @description   Ein Klick auf tel: und callto: Links soll über den 3cx Webclient einen Anruf starten.
// ==/UserScript==

// requires jQuery

// Insert your 3cx base URL here:
const my3cxUrl = 'https://xxx.my3cx.de';

function fixTelLinks() {
  var telLinks = $('a[href^="tel:"], a[href^="callto:"]');
  console.log(telLinks);
  telLinks.each((idx, elem) => {
    var href = decodeURI(elem.href); // Fix: Wer würde denken, dass elem.href URI-encoded ist?
    href = my3cxUrl + '/webclient/#/call?phone=' + encodeURIComponent(href.replace(/[^0-9+]/g, ''));
    elem.href = href;
    elem.target = '_blank';
  });
}

$(function() {
  // Wait a short time before fixing links because some sites need
  // some time to build up the page (e.g. HTTP requests for JSON data)
  setTimeout(fixTelLinks, 1000);
});