|
1 | 1 | // ==UserScript==
|
2 | 2 |
|
3 | 3 | // @name More Awesome Azure DevOps (userscript)
|
4 |
| -// @version 3.5.3 |
| 4 | +// @version 3.6.0 |
5 | 5 | // @author Alejandro Barreto (NI)
|
6 | 6 | // @description Makes general improvements to the Azure DevOps experience, particularly around pull requests. Also contains workflow improvements for NI engineers.
|
7 | 7 | // @license MIT
|
|
24 | 24 | // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js#sha384-8oDwN6wixJL8kVeuALUvK2VlyyQlpEEN5lg6bG26x2lvYQ1HWAV0k8e2OwiWIX8X
|
25 | 25 | // @require https://gist.githubusercontent.com/alejandro5042/af2ee5b0ad92b271cd2c71615a05da2c/raw/45da85567e48c814610f1627148feb063b873905/easy-userscripts.js#sha384-t7v/Pk2+HNbUjKwXkvcRQIMtDEHSH9w0xYtq5YdHnbYKIV7Jts9fSZpZq+ESYE4v
|
26 | 26 |
|
27 |
| -// @require https://unpkg.com/@popperjs/core@2#sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB |
28 |
| -// @require https://unpkg.com/tippy.js@6#sha384-AiTRpehQ7zqeua0Ypfa6Q4ki/ddhczZxrKtiQbTQUlJIhBkTeyoZP9/W/5ulFt29 |
| 27 | +// @require https://unpkg.com/@popperjs/core@2.11.7#sha384-zYPOMqeu1DAVkHiLqWBUTcbYfZ8osu1Nd6Z89ify25QV9guujx43ITvfi12/QExE |
| 28 | +// @require https://unpkg.com/tippy.js@6.3.7#sha384-AiTRpehQ7zqeua0Ypfa6Q4ki/ddhczZxrKtiQbTQUlJIhBkTeyoZP9/W/5ulFt29 |
29 | 29 |
|
30 | 30 | // @require https://highlightjs.org/static/highlight.min.js
|
31 | 31 | // @require https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.14.0/js-yaml.min.js#sha512-ia9gcZkLHA+lkNST5XlseHz/No5++YBneMsDp1IZRJSbi1YqQvBeskJuG1kR+PH1w7E0bFgEZegcj0EwpXQnww==
|
|
132 | 132 | watchForStatusCardAndMoveToRightSideBar(session);
|
133 | 133 | addEditButtons(session);
|
134 | 134 | addTrophiesToPullRequest(session, pageData);
|
| 135 | + fixImageUrls(session); |
135 | 136 | });
|
136 | 137 |
|
137 | 138 | eus.onUrl(/\/(agentqueues|agentpools)(\?|\/)/gi, (session, urlMatch) => {
|
|
2185 | 2186 | }
|
2186 | 2187 | }
|
2187 | 2188 |
|
| 2189 | + // Fix PR image URLs to match the window URL (whether dev.azure.com/account/ or account.visualstudio.com/) |
| 2190 | + function fixImageUrls(session) { |
| 2191 | + let account; |
| 2192 | + let badPrefix; |
| 2193 | + let goodPrefix; |
| 2194 | + if (window.location.host === 'dev.azure.com') { |
| 2195 | + account = window.location.pathname.match(/^\/(\w+)/)[1]; |
| 2196 | + badPrefix = new RegExp(`^${window.location.protocol}//${account}.visualstudio.com/`); |
| 2197 | + goodPrefix = `${window.location.protocol}//dev.azure.com/${account}/`; |
| 2198 | + } else { |
| 2199 | + const match = window.location.host.match(/^(\w+)\.visualstudio.com/); |
| 2200 | + if (!match) return; |
| 2201 | + account = match[1]; |
| 2202 | + badPrefix = new RegExp(`^${window.location.protocol}//dev.azure.com/${account}/`); |
| 2203 | + goodPrefix = `${window.location.protocol}//${account}.visualstudio.com/`; |
| 2204 | + } |
| 2205 | + |
| 2206 | + session.onEveryNew(document, 'img', img => { |
| 2207 | + const src = img.getAttribute('src'); |
| 2208 | + if (src && src.match(badPrefix)) { |
| 2209 | + // For debugging: debug("Fixing img src", src); |
| 2210 | + img.setAttribute('src', src.replace(badPrefix, goodPrefix)); |
| 2211 | + } |
| 2212 | + }); |
| 2213 | + } |
| 2214 | + |
2188 | 2215 | // Helper function to get the file extension out of a file path; e.g. `cs` from `blah.cs`.
|
2189 | 2216 | function getFileExt(path) {
|
2190 | 2217 | return /(?:\.([^.]+))?$/.exec(path)[1];
|
|
0 commit comments