Greasy Fork镜像 支持简体中文。

Azure DevOps Commit Compare

Compare commits like pull requests

  1. // ==UserScript==
  2. // @name Azure DevOps Commit Compare
  3. // @namespace https://fxzfun.com/userscripts
  4. // @version 1.0.0
  5. // @description Compare commits like pull requests
  6. // @author FXZFun
  7. // @match https://dev.azure.com/*/*/_git/*/commit/*
  8. // @match https://dev.azure.com/*/*/_git/*
  9. // @icon https://cdn.vsassets.io/content/icons/favicon.ico
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function run() {
  17. if (document.getElementById("__bolt-compare-commits")) return;
  18.  
  19. const commitId = location.href.match(/(?<=commit\/)(.+)(?=\?)/gi)?.[0];
  20. const storedCommitId = localStorage.getItem("azureDevOpsCommitCompareId");
  21.  
  22. document.getElementById("__bolt-browse-files").insertAdjacentHTML("beforeBegin",
  23. `<a aria-roledescription="link"
  24. class="bolt-header-command-item-button bolt-button bolt-link-button enabled ${storedCommitId && "primary"} bolt-focus-treatment"
  25. data-focuszone="focuszone-3"
  26. data-is-focusable="true"
  27. id="__bolt-compare-commits"
  28. role="menuitem"
  29. tabindex="0">
  30. <span class="bolt-button-text body-m">${storedCommitId ? "Start Compare" : "Compare Commits"}</span>
  31. </a>`);
  32.  
  33. document.getElementById("__bolt-compare-commits").addEventListener("click", () => {
  34. let url = location.href.substring(0, location.href.indexOf('commit'));
  35.  
  36. if (!storedCommitId) {
  37. localStorage.setItem("azureDevOpsCommitCompareId", commitId);
  38. url += "commits";
  39. } else {
  40. localStorage.removeItem("azureDevOpsCommitCompareId");
  41. url += `/branchCompare?baseVersion=GC${storedCommitId}&targetVersion=GC${commitId}&_a=files`;
  42. }
  43.  
  44. location.href = url;
  45. });
  46. }
  47.  
  48. let currentURL = "";
  49. setInterval(() => {
  50. if (location.href !== currentURL && /https:\/\/dev\.azure\.com\/.*\/.*\/_git\/.*\/commit\/.*/.test(location.href)) {
  51. run()
  52. currentURL = location.href;
  53. }
  54. }, 1000); // Check every second
  55.  
  56. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址