3cx Click2Call

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
});