Jira history diff

Highliht diff in Jira issue history.

  1. // ==UserScript==
  2. // @name Jira history diff
  3. // @version 2025-05-28
  4. // @description Highliht diff in Jira issue history.
  5. // @author vctls
  6. // @match https://*.atlassian.net/*
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
  8. // @grant none
  9. // @require https://cdn.jsdelivr.net/gh/google/diff-match-patch@62f2e689f498f9c92dbc588c58750addec9b1654/javascript/diff_match_patch_uncompressed.js
  10. // @license MIT
  11. // @namespace https://gf.qytechs.cn/users/299396
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const handleMessage = () => {
  18.  
  19. // Get all history entries that have description changes.
  20. // TODO Find a more reliable selector.
  21. const descChanges = document.querySelectorAll('[data-testid="issue-history.ui.history-items.generic-history-item.history-item"] >:nth-child(2):has(div:nth-child(1) > ._1reo1wug) ._1e0c1txw');
  22.  
  23. descChanges.forEach((element, index) => {
  24. if (element.dataset.diffed) return;
  25. const right = element.querySelector('._syaz1fxt:nth-of-type(1) ._1reo1wug');
  26. // nth-of-type(2) is the arrow icon between left and right items
  27. const left = element.querySelector('._syaz1fxt:nth-of-type(3) ._1reo1wug');
  28.  
  29. if (!left || !right) return;
  30. element.style.display = "block";
  31. const dmp = new diff_match_patch();
  32. const diff = dmp.diff_main(right.innerText, left.innerText);
  33. dmp.diff_cleanupSemantic(diff);
  34. element.innerHTML = dmp.diff_prettyHtml(diff);
  35. element.dataset.diffed = true;
  36. });
  37. };
  38.  
  39. let timeoutId;
  40. const delayedHandler = () => {
  41. clearTimeout(timeoutId);
  42. timeoutId = setTimeout(() => handleMessage(), 10);
  43. };
  44.  
  45. (new MutationObserver(delayedHandler)).observe(document, {childList: true, subtree: true});
  46.  
  47. })();

QingJ © 2025

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