Greasy Fork 还支持 简体中文。

Jira Image Linker

Add a hyperlink to image tags in Jira comments

  1. // ==UserScript==
  2. // @name Jira Image Linker
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Add a hyperlink to image tags in Jira comments
  6. // @author Zetaphor
  7. // @match https://jira.ipgaxis.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let interval = null;
  16.  
  17. function wrapImagesInLinks() {
  18. const imageWraps = document.querySelectorAll('.image-wrap');
  19.  
  20. imageWraps.forEach(imageWrap => {
  21. const imageTag = imageWrap.querySelector('img');
  22.  
  23. if (imageTag) {
  24. const imageSource = imageTag.getAttribute('src');
  25. const imageLink = document.createElement('a');
  26. imageLink.href = imageSource;
  27. imageLink.target = '_blank';
  28.  
  29. imageWrap.replaceChild(imageLink, imageTag);
  30. imageLink.appendChild(imageTag);
  31. }
  32. });
  33. }
  34.  
  35. function observeDOM() {
  36. const targetNode = document.querySelector('.activity-comment');
  37.  
  38. if (targetNode) {
  39. clearInterval(interval);
  40. wrapImagesInLinks();
  41. } else {
  42. setTimeout(observeDOM, 1000);
  43. }
  44. }
  45.  
  46. interval = setInterval(observeDOM, 1000);
  47. })();