]> src.twobees.de Git - tampermonkeyscripts.git/commitdiff
Add initial version
authorTobias Sachs <src.twobees.de-co0Chie-ts@ctsachs.de>
Wed, 5 Aug 2020 12:17:37 +0000 (14:17 +0200)
committerTobias Sachs <src.twobees.de-co0Chie-ts@ctsachs.de>
Wed, 5 Aug 2020 12:57:16 +0000 (14:57 +0200)
Commitmessage in discussion and history tab get altert to have visible line breaks.
Also a link to the changeset is added.

AzureDevOpsCommentEnhancer.user.js [new file with mode: 0644]

diff --git a/AzureDevOpsCommentEnhancer.user.js b/AzureDevOpsCommentEnhancer.user.js
new file mode 100644 (file)
index 0000000..ba3df44
--- /dev/null
@@ -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*):/, "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>:<br />");
+                el.innerHTML = html.replace(/\n/gi, "<br />");
+            }
+        }
+    };
+    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();
+
+})();