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.10: #Bugnumber to links, highlight comments for customors in checkins
14 // 0.09: update download/update URLs
15 // 0.08: fix typos/formatting
16 // 0.07: fix work item tampering
17 // 0.06: Add link to Changeset in diff view
19 /* jshint esversion:6 */
24 let fixWorkitems = () => {
25 let found = document.getElementsByClassName("comment-content");
26 fixCommentContents(found);
28 found = document.getElementsByClassName("history-item-comment");
29 fixCommentContents(found);
31 console.debug("observe...");
34 let fixCommentContents = (items) => {
35 if (items === null || items === undefined || items.length === 0) {
38 console.info("fixing '" + items.length +"' comments.");
39 for (var i = 0; i < items.length; i++) {
41 let html = el.innerHTML;
42 if (html.startsWith("Associated")) {
43 html = html.replace(/(Associated with changeset )(\d*):/,
44 "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>:<br />");
45 html = html.replace(/#(\d+)/g, "<a href='/HeBa/Entwicklung/_versionControl/changeset/$1'>#$1</a>");
46 html = html.replace(/\n/gi, "<br />");
47 html = html.replace(/(@@CUST.*)/s, "<br><span style=\"color: green; font-style:italic;\">$1</span>");
53 let fixVersionControl = () => {
55 let found = document.getElementsByClassName("changeset-version")[0];
60 // if opened from email notification, it is the first span in div "changeset-version"
61 elToFix = found.querySelector("span");
67 elToFix.innerHTML = elToFix.innerHTML
68 .replace(/(Changeset )(\d+)/,
69 "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
74 console.debug("fixit timerreset...");
75 clearTimeout(timerId);
78 observer.disconnect();
80 timerId = setTimeout(function() {
83 let url = window.location.href;
85 if (url.includes("/_versionControl")) {
89 // if (url.includes("/_workitems")){
90 // does not work since workitems are often shown in
91 // dialogs on random pages
95 // keep watching for changes
96 observer.observe(document, { subtree: true, childList: true, characterData: true });
100 const observer = new MutationObserver(function() {
101 console.debug('observer was triggered...');