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.8: fix typos/formatting
14 // 0.7: fix work item tampering
15 // 0.6: Add link to Changeset in diff view
19 let timerId = undefined;
21 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...");
31 let fixCommentContents = (items) => {
32 if (items === null || items === undefined || items.length === 0) {
35 console.info("fixing '" + items.length +"' comments.");
36 for (var i = 0; i < items.length; i++) {
38 let html = el.innerHTML;
39 if (html.startsWith("Associated")) {
40 html = html.replace(/(Associated with changeset )(\d*):/, "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>:<br />");
41 el.innerHTML = html.replace(/\n/gi, "<br />");
46 let fixVersionControl = () => {
48 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");
60 elToFix.innerHTML = elToFix.innerHTML.replace(/(Changeset )(\d+)/, "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
65 console.debug("fixit timerreset...");
66 clearTimeout(timerId);
69 observer.disconnect();
71 timerId = setTimeout(function() {
74 let url = window.location.href;
76 if (url.includes("/_versionControl")) {
80 // if (url.includes("/_workitems")){
81 // does not work since workitems are often shown in
82 // dialogs on random pages
86 // keep watching for changes
87 observer.observe(document, { subtree: true, childList: true, characterData: true });
91 const observer = new MutationObserver(function() {
92 console.debug('observer was triggered...');