From 0d709724a4c3800f1e3ead3a8a475370afcf8ee8 Mon Sep 17 00:00:00 2001 From: Tobias Sachs Date: Wed, 5 Aug 2020 14:17:37 +0200 Subject: [PATCH] Add initial version Commitmessage in discussion and history tab get altert to have visible line breaks. Also a link to the changeset is added. --- AzureDevOpsCommentEnhancer.user.js | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 AzureDevOpsCommentEnhancer.user.js 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(); + +})(); -- 2.39.5