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.9: update download/update URLs
14 // 0.8: fix typos/formatting
15 // 0.7: fix work item tampering
16 // 0.6: Add link to Changeset in diff view
20 let timerId = undefined;
22 let fixWorkitems = () => {
23 let found = document.getElementsByClassName("comment-content");
24 fixCommentContents(found);
26 found = document.getElementsByClassName("history-item-comment");
27 fixCommentContents(found);
29 console.debug("observe...");
32 let fixCommentContents = (items) => {
33 if (items === null || items === undefined || items.length === 0) {
36 console.info("fixing '" + items.length +"' comments.");
37 for (var i = 0; i < items.length; i++) {
39 let html = el.innerHTML;
40 if (html.startsWith("Associated")) {
41 html = html.replace(/(Associated with changeset )(\d*):/, "<b>$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a></b>:<br />");
42 el.innerHTML = html.replace(/\n/gi, "<br />");
47 let fixVersionControl = () => {
49 let found = document.getElementsByClassName("changeset-version")[0];
54 // if opened from email notification, it is the first span in div "changeset-version"
55 elToFix = found.querySelector("span");
61 elToFix.innerHTML = elToFix.innerHTML.replace(/(Changeset )(\d+)/, "$1<a href='/HeBa/Entwicklung/_versionControl/changeset/$2'>$2</a>");
66 console.debug("fixit timerreset...");
67 clearTimeout(timerId);
70 observer.disconnect();
72 timerId = setTimeout(function() {
75 let url = window.location.href;
77 if (url.includes("/_versionControl")) {
81 // if (url.includes("/_workitems")){
82 // does not work since workitems are often shown in
83 // dialogs on random pages
87 // keep watching for changes
88 observer.observe(document, { subtree: true, childList: true, characterData: true });
92 const observer = new MutationObserver(function() {
93 console.debug('observer was triggered...');