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.11: #fix comments in Bugs opened via mention email notification
14 // 0.10: #Bugnumber to links, highlight comments for customors in checkins
15 // 0.09: update download/update URLs
16 // 0.08: fix typos/formatting
17 // 0.07: fix work item tampering
18 // 0.06: Add link to Changeset in diff view
20 /* jshint esversion:6 */
25 let fixWorkitems = () => {
26 console.debug("fixWorkitems...");
27 let found = document.getElementsByClassName("comment-content");
28 if (fixCommentContents(found)) return;
30 found = document.getElementsByClassName("history-item-comment");
31 if (fixCommentContents(found)) return;
33 found = document.getElementsByClassName("comments-section");
34 if (fixCommentContents(found)) return;
36 console.debug("... notihing found to fix..");
39 let fixCommentContents = (items) => {
40 if (items === null || items === undefined || items.length === 0) {
43 console.info("fixing '" + items.length +"' comments.");
44 for (var i = 0; i < items.length; i++) {
46 let html = el.innerHTML;
47 if (html.startsWith("Associated")) {
48 html = html.replace(/(Associated with changeset )(\d*):/,
49 "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>:<br />");
50 html = html.replace(/#(\d+)/g, "<a href='/HeBa/Entwicklung/_versionControl/changeset/$1'>#$1</a>");
51 html = html.replace(/\n/gi, "<br />");
52 html = html.replace(/(@@CUST.*)/s, "<br><span style=\"color: green; font-style:italic;\">$1</span>");
59 let fixVersionControl = () => {
61 let found = document.getElementsByClassName("changeset-version")[0];
66 // if opened from email notification, it is the first span in div "changeset-version"
67 elToFix = found.querySelector("span");
73 elToFix.innerHTML = elToFix.innerHTML
74 .replace(/(Changeset )(\d+)/,
75 "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
80 console.debug("fixit timerreset...");
81 clearTimeout(timerId);
84 observer.disconnect();
86 timerId = setTimeout(function() {
89 let url = window.location.href;
91 if (url.includes("/_versionControl")) {
95 // if (url.includes("/_workitems")){
96 // does not work since workitems are often shown in
97 // dialogs on random pages
101 // keep watching for changes
102 observer.observe(document, { subtree: true, childList: true, characterData: true });
106 const observer = new MutationObserver(function() {
107 console.debug('observer was triggered...');