3cx Click2Call

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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