TriXxieDK / Customer warnings

// ==UserScript==
// @name         Customer warnings
// @namespace    https://openuserjs.org/users/TriXxieDK
// @version      0.1
// @description  Pop up an alert box when selecting certain customer on create invoice page
// @author       TriXxieDK
// @match        https://secure.e-conomic.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

var warnings = {
    //'customer number': 'Warning message',
    '37': 'Say hi to customer from William',
};
var warned = false;

(function() {
    'use strict';

    var whenModified = function () {
        var custnum = $("div.invoice__customer__number > span:nth-child(2)").text();
        if ((warnings[custnum] !== null) && (!warned)) {
            alert(warnings[custnum]);
            warned = true;
        }
    };
    $('body').bind("DOMSubtreeModified", whenModified);

})();