From: Tobias Sachs Date: Wed, 5 Aug 2020 12:17:37 +0000 (+0200) Subject: Add initial version X-Git-Url: https://src.twobees.de/?a=commitdiff_plain;h=98aa74e4886b4cfe1f87d248257e2448686e4a3e;p=tampermonkeyscripts.git Add initial version Commitmessage in discussion and history tab get altert to have visible line breaks. Also a link to the changeset is added. --- 98aa74e4886b4cfe1f87d248257e2448686e4a3e diff --git a/AzureDevOpsCommentEnhancer.user.js b/AzureDevOpsCommentEnhancer.user.js new file mode 100644 index 0000000..ba3df44 --- /dev/null +++ b/AzureDevOpsCommentEnhancer.user.js @@ -0,0 +1,57 @@ +// ==UserScript== +// @name Fix ADS checkin comments in discussion and history of workitems +// @version 0.1 +// @author Tobias Sachs +// ... add match eg https://myazerdevops/* +// @match https:// +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + let timerId = undefined; + let fixComments = (items) => + { + if (items === null || items === undefined || items.length === 0) + { + return; + } + console.info("fixing '" + items.length +"' comments."); + for (var i = 0; i < items.length; i++){ + let el = items[i]; + let html = el.innerHTML; + if (html.startsWith("Associated")) + { + html = html.replace(/(Associated with changeset )(\d*):/, "$1$2:
"); + el.innerHTML = html.replace(/\n/gi, "
"); + } + } + }; + let fixit = () => { + if (timerId){ + console.debug("fixit timerreset..."); + clearTimeout(timerId); + } + + observer.disconnect(); + timerId = setTimeout(function(){ + timerId = undefined; + let found = document.getElementsByClassName("comment-content"); + fixComments(found); + + found = document.getElementsByClassName("history-item-comment"); + fixComments(found); + + console.debug("observe..."); + observer.observe(document, { subtree: true, childList: true, characterData: true }); + }, 300); + }; + + const observer = new MutationObserver(function() { + console.debug('observertriggered...'); + fixit(); + }); + + fixit(); + +})();