whatnowmax / case_update_first_only

// ==UserScript==
// @name case_update_first_only
// @description case_update_first_only
// @version 1.0
// @author whatnowmax
// @license MIT
// @match https://crm.stagrp.com/index.php?action=DetailView&module=Cases&record=*
// @match https://crm.stagrp.com/index.php?module=Cases*

// @run-at document-end
// @grant none
// ==/UserScript==

        replaceCaseUpdateFirst("caseUpdate");


function replaceCaseUpdateFirst(_field) {
    var _caseUPs = document.getElementsByClassName(_field);
    console.log("Removing extra emails for " + _caseUPs.id);

    //for each case update
    for (var i = 0; i < _caseUPs.length; i++){
        var _border = '<div style="border:none;border-top:solid #E1E1E1 1pt;padding:3pt 0in 0in 0in;"';
        //split by _border
        var _spl = _caseUPs[i].innerHTML.split(_border);

        //we only want to replace the update if a border was found. Otherwise it's a direct case update from customer or engineer
        if (_spl[0] !== '') {
            _caseUPs[i].innerHTML = _spl[0];
        }
        //console.log(_caseUPs[i]);
    }
}