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.7: fix work item tampering
14 // 0.6: Add link to Changeset in diff view
18 let timerId = undefined;
20 let fixWorkitems = () =>
22 let found = document.getElementsByClassName("comment-content");
23 fixCommentContents(found);
25 found = document.getElementsByClassName("history-item-comment");
26 fixCommentContents(found);
28 console.debug("observe...");
30 let fixCommentContents = (items) =>
32 if (items === null || items === undefined || items.length === 0)
36 console.info("fixing '" + items.length +"' comments.");
37 for (var i = 0; i < items.length; i++){
39 let html = el.innerHTML;
40 if (html.startsWith("Associated"))
42 html = html.replace(/(Associated with changeset )(\d*):/, "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>:<br />");
43 el.innerHTML = html.replace(/\n/gi, "<br />");
48 let fixVersionControl = () =>
51 let found = document.getElementsByClassName("changeset-version")[0];
53 // if opened from email notification it is the first span in div "changeset-version"
54 elToFix = found.querySelector("span");
58 // if opened from histrory in ads it is the span in div "changeset-id"
59 // elToFix = document.getElementsByClassName("changeset-id")[0];
66 elToFix.innerHTML = elToFix.innerHTML.replace(/(Changeset )(\d+)/, "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
72 console.debug("fixit timerreset...");
73 clearTimeout(timerId);
76 observer.disconnect();
78 timerId = setTimeout(function(){
81 let url = window.location.href;
83 if (url.includes("/_versionControl"))
88 // if (url.includes("/_workitems")){
89 // does not work since workitem are often shown in
90 // diaolgs on random pages
94 // keep watching for changes.
95 observer.observe(document, { subtree: true, childList: true, characterData: true });
99 const observer = new MutationObserver(function() {
100 console.debug('observertriggered...');