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://src.twobees.de/?p=tampermonkeyscripts.git;a=blob_plain;f=AzureDevOpsCommentEnhancer.user.js;hb=HEAD
8 // @downloadURL https://src.twobees.de/?p=tampermonkeyscripts.git;a=blob_plain;f=AzureDevOpsCommentEnhancer.user.js;hb=HEAD
13 // 0.12: also fix "Resolved with changeset" comments
14 // 0.11: fix regexp for later changesets attached.
15 // 0.10: #Bugnumber to links, highlight comments for customors in checkins
16 // 0.09: updateq download/update URLs
17 // 0.08: fix typregexp for later changesets attachedos/formatting
18 // 0.07: fix work itlsem tampering
19 // 0.06: Add link to Changeset in diff view
21 /* jshint esversion:6 */
26 let fixWorkitems = () => {
27 let found = document.getElementsByClassName("comment-content");
28 fixCommentContents(found);
30 found = document.getElementsByClassName("history-item-comment");
31 fixCommentContents(found);
33 console.debug("observe...");
36 let fixCommentContents = (items) => {
37 if (items === null || items === undefined || items.length === 0) {
40 console.info("fixing '" + items.length +"' comments.");
41 for (var i = 0; i < items.length; i++) {
43 let html = el.innerHTML;
45 if (html.startsWith("Associated") || html.startsWith("Resolved")) {
46 html = html.replace(/((Associated|Resolved) with changeset )(\d*)([:.])/,
47 "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$3'>$3</a></b>$4<br />");
48 html = html.replace(/#(\d+)/g, "<a href='/HeBa/Entwicklung/_versionControl/changeset/$1'>#$1</a>");
49 html = html.replace(/\n/gi, "<br />");
50 html = html.replace(/(@@CUST.*)/s, "<br><span style=\"color: green; font-style:italic;\">$1</span>");
56 let fixVersionControl = () => {
58 let found = document.getElementsByClassName("changeset-version")[0];
63 // if opened from email notification, it is the first span in div "changeset-version"
64 elToFix = found.querySelector("span");
70 elToFix.innerHTML = elToFix.innerHTML
71 .replace(/(Changeset )(\d+)/,
72 "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
77 console.debug("fixit timerreset...");
78 clearTimeout(timerId);
81 observer.disconnect();
83 timerId = setTimeout(function() {
86 let url = window.location.href;
88 if (url.includes("/_versionControl")) {
92 // if (url.includes("/_workitems")){
93 // does not work since workitems are often shown in
94 // dialogs on random pages
98 // keep watching for changes
99 observer.observe(document, { subtree: true, childList: true, characterData: true });
103 const observer = new MutationObserver(function() {
104 console.debug('observer was triggered...');