Fendo / AAO Click Counter

// ==UserScript==
// @name         AAO Click Counter
// @namespace    https://openuserjs.org/users/Fendo
// @version      1.0
// @description  Verbesserter Klickzähler für Leitstellen AAO
// @copyright    2017, Fendo (https://openuserjs.org/users/Fendo)
// @license      CC-BY-NC-SA-4.0; https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
// @license      GPL-3.0+; http://www.gnu.org/licenses/gpl-3.0.txt
// @match        *://www.leitstellenspiel.de/*
// @exclude      *://www.leitstellenspiel.de/?mapview=true
// @grant        GM_addStyle
// @updateURL    https://openuserjs.org/meta/Fendo/AAO_Click_Counter.meta.js
// @run          document-start
// ==/UserScript==

//Add Styles
GM_addStyle(".fendo-aao-cc { border-radius: 8px; position: relative; top: -20px; z-index: 1000; background: red; color: white; width: 16px; height: 16px; left: -8px; display:none; }");

//Change Style
(function () {
    $('body').prepend(
        '<style type="text/css" id="fendos_style">'+
        '.aao{height:20px!important;}'+
        '.vehicle_group{height:20px!important;}'+
        '</style>'
    );})();

//clickcounter
(function ($) {

    function checksite() {
        return !!window.location.href.match(/https:\/\/www\.[a-z]+\.[a-z]+\/missions\/[0-9]+$/g);
    }

    function createcounter() {
        $('.aao').each(function () {
            $(this).append('<div id="aaocounter" class="fendo-aao-cc">0</div>');
        });

        $('[vehicle_group_id]').each(function () {
            $(this).append('<div id="aaocounter" class="fendo-aao-cc">0</div>');
        });
    }

    function raisecounter(element) {
        var aaocounter = parseInt($(element).find('.fendo-aao-cc').html());
        ++aaocounter;
        $(element).find('#aaocounter').html(aaocounter);
        $(element).find('#aaocounter').css('display', 'block');
    }

    if (checksite()) {
        createcounter();

        $('.aao').bind('click', function () {
            raisecounter(this);
        });

        $('[vehicle_group_id]').bind('click', function () {
            raisecounter(this);
        });
    }
})($);