2 // @name Fix ADS checkin comments in discussion and history of workitems
4 // @author Tobias Sachs
5 // ... in @match replace "ads" with the url of you Azure DevOps Server
6 // @match https://ads/*
7 // @updateURL https://github.com/tsheba/tampermonkeyscripts/raw/master/AzureDevOpsCommentEnhancer.user.js
8 // @downloadURL https://github.com/tsheba/tampermonkeyscripts/raw/master/AzureDevOpsCommentEnhancer.user.js
13 // 0.6: Add link to Changeset in diff view
17 let timerId = undefined;
19 let fixWorkitems = () =>
21 let found = document.getElementsByClassName("comment-content");
22 fixCommentContents(found);
24 found = document.getElementsByClassName("history-item-comment");
25 fixCommentContents(found);
27 console.debug("observe...");
29 let fixCommentContents = (items) =>
31 if (items === null || items === undefined || items.length === 0)
35 console.info("fixing '" + items.length +"' comments.");
36 for (var i = 0; i < items.length; i++){
38 let html = el.innerHTML;
39 if (html.startsWith("Associated"))
41 html = html.replace(/(Associated with changeset )(\d*):/, "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>:<br />");
42 el.innerHTML = html.replace(/\n/gi, "<br />");
47 let fixVersionControl = () =>
50 let found = document.getElementsByClassName("changeset-version")[0];
52 // if opened from email notification it is the first span in div "changeset-version"
53 elToFix = found.querySelector("span");
57 // if opened from histrory in ads it is the span in div "changeset-id"
58 // elToFix = document.getElementsByClassName("changeset-id")[0];
65 elToFix.innerHTML = elToFix.innerHTML.replace(/(Changeset )(\d+)/, "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
71 console.debug("fixit timerreset...");
72 clearTimeout(timerId);
75 observer.disconnect();
77 timerId = setTimeout(function(){
80 let url = window.location.href;
82 if (url.includes("/_versionControl"))
86 else if (url.includes("/_workitems")){
91 console.info("nothing to do here");
95 // keep watching for changes.
96 observer.observe(document, { subtree: true, childList: true, characterData: true });
100 const observer = new MutationObserver(function() {
101 console.debug('observertriggered...');