Auto Expand Subtasks - Asana

Auto Expand sub-tasks of selected Task and collapse other Tasks.

  1. // ==UserScript==
  2. // @name Auto Expand Subtasks - Asana
  3. // @name:de Unteraufgaben Automatisch anzeigen - Asana
  4. // @namespace https://gf.qytechs.cn/users/928242
  5. // @version 0.1
  6. // @description Auto Expand sub-tasks of selected Task and collapse other Tasks.
  7. // @description:de Klappt automatisch die Unteraufgaben der ausgewählten Aufgabe aus und schließt die anderen.
  8. // @author Kamikaze (https://github.com/Kamiikaze)
  9. // @supportURL https://github.com/Kamiikaze/Tampermonkey/issues
  10. // @match https://app.asana.com/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=asana.com
  12. // @grant none
  13. // @run-at document-ready
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. console.log("Started [Auto Expand Subtasks - Asana]")
  18.  
  19. let checkReadyState = setInterval( () => {
  20. if (document.readyState === 'complete') addAutoExpand()
  21. }, 1000)
  22.  
  23. function collapseTasks() {
  24. const subTaskButtons = document.querySelectorAll(".ProjectSpreadsheetGridRow-subtaskToggleButton")
  25.  
  26. for (let el = 0; el < subTaskButtons.length; el++) {
  27. const item = subTaskButtons[el]
  28. const isExpanded = item.childNodes[0].classList.contains("DownTriangleIcon")
  29.  
  30. if(isExpanded) item.click()
  31. }
  32. }
  33.  
  34. function addAutoExpand() {
  35. clearInterval(checkReadyState)
  36.  
  37. const taskItems = document.querySelectorAll(".SpreadsheetRow-stickyCell")
  38.  
  39. for (let el = 0; el < taskItems.length; el++) {
  40. const item = taskItems[el]
  41. item.addEventListener("click", () => {
  42. collapseTasks()
  43.  
  44. const toggleButton = item.querySelector(".ProjectSpreadsheetGridRow-subtaskToggleButton")
  45. toggleButton.click()
  46. })
  47. }
  48. }

QingJ © 2025

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