Click to Not Edit

Prevents click-to-edit in JIRA (matches JIRA Cloud URLs by default)

  1. // ==UserScript==
  2. // @name Click to Not Edit
  3. // @match *://*.atlassian.net/*
  4. // @run-at document-start
  5. // @license ISC
  6. // @version 0.0.1.20201222233052
  7. // @namespace https://gf.qytechs.cn/users/719533
  8. // @description Prevents click-to-edit in JIRA (matches JIRA Cloud URLs by default)
  9. // ==/UserScript==
  10. //
  11. // This is supposed to disable click-to-edit in Jira unless ctrl or cmd is held.
  12.  
  13. document.addEventListener('click',
  14. ((event)=>{
  15. if (event.metaKey || event.ctrlKey){
  16. return; // allow normal click-to-edit when key is held
  17. }
  18. var e = event.target;
  19. if (e.tagName=='A'){
  20. return; // allow normal click on normal hyperlinks
  21. }
  22. while (e != document){
  23. var aa = e.attributes;
  24. for (var i=0; i<aa.length; ++i){
  25. var a = aa[i];
  26. if(a.name=='role' && a.value=='presentation' && e.tagName!='SPAN'){
  27. // This is an attempt to cleanly match relevant elements (comments, description) despite class obfuscation.
  28. // Excluding <span> avoids inhibiting clicks on attach/link buttons.
  29.  
  30. console.log("CLICKED TO NOT EDIT, hold ctrl/cmd if you really want the thing to happen");
  31. event.preventDefault(); event.stopPropagation(); return false;
  32. };
  33. }
  34. e = e.parentNode;
  35. }
  36. }),
  37. {capture: true})

QingJ © 2025

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