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 regexp for later changesets attached.
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 let found = document.getElementsByClassName("comment-content");
27 fixCommentContents(found);
29 found = document.getElementsByClassName("history-item-comment");
30 fixCommentContents(found);
32 console.debug("observe...");
35 let fixCommentContents = (items) => {
36 if (items === null || items === undefined || items.length === 0) {
39 console.info("fixing '" + items.length +"' comments.");
40 for (var i = 0; i < items.length; i++) {
42 let html = el.innerHTML;
43 if (html.startsWith("Associated")) {
44 html = html.replace(/(Associated with changeset )(\d*)([:.])/,
45 "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>$3<br />");
46 html = html.replace(/#(\d+)/g, "<a href='/HeBa/Entwicklung/_versionControl/changeset/$1'>#$1</a>");
47 html = html.replace(/\n/gi, "<br />");
48 html = html.replace(/(@@CUST.*)/s, "<br><span style=\"color: green; font-style:italic;\">$1</span>");
54 let fixVersionControl = () => {
56 let found = document.getElementsByClassName("changeset-version")[0];
61 // if opened from email notification, it is the first span in div "changeset-version"
62 elToFix = found.querySelector("span");
68 elToFix.innerHTML = elToFix.innerHTML
69 .replace(/(Changeset )(\d+)/,
70 "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
75 console.debug("fixit timerreset...");
76 clearTimeout(timerId);
79 observer.disconnect();
81 timerId = setTimeout(function() {
84 let url = window.location.href;
86 if (url.includes("/_versionControl")) {
90 // if (url.includes("/_workitems")){
91 // does not work since workitems are often shown in
92 // dialogs on random pages
96 // keep watching for changes
97 observer.observe(document, { subtree: true, childList: true, characterData: true });
101 const observer = new MutationObserver(function() {
102 console.debug('observer was triggered...');