Tapd小助手

Tpad小助手

  1. // ==UserScript==
  2. // @name Tapd小助手
  3. // @namespace tapd
  4. // @version 0.1.1
  5. // @description Tpad小助手
  6. // @author yaxinliu
  7. // @include *://tapd.oa.com/*
  8. // @include *://tapd.woa.com/*
  9. // @icon http://tapd.oa.com/favicon.ico
  10. // @grant none
  11. // @run-at document-body
  12. // @license Private
  13. // ==/UserScript==
  14.  
  15. (function($) {
  16. 'use strict';
  17.  
  18. class DOMNode {
  19. constructor (selector) {
  20. this.selector = selector
  21. this.timmer = null
  22. this.triggered = false
  23. }
  24.  
  25. onReady(callback) {
  26. const self = this
  27. document.addEventListener("DOMSubtreeModified", function(event) {
  28. const target = event.target
  29. if (self.triggered) {
  30. return
  31. }
  32. if (target !== document.querySelector(self.selector)) {
  33. return
  34. }
  35. if (self.timmer) {
  36. clearTimeout(self.timmer)
  37. }
  38. self.timmer = setTimeout(() => {
  39. self.triggered = true
  40. callback()
  41. }, 100)
  42. })
  43. }
  44. }
  45.  
  46. const className = ".iteration_gird #div_tabs .member-bar"
  47. const dom = new DOMNode(className)
  48. dom.onReady(function() {
  49. const $elem = $(`<div class="member-left-block" style="float: left; margin-top: 10px;">
  50. <div>
  51. <a class="font font-unfold fold-operation unfold-all" style="user-select:none;">&nbsp;&nbsp;全部展开</a>
  52. </div>
  53. </div>`)
  54. $(className).append($elem)
  55. $elem.click(function() {
  56. const $this = $(this).find(".fold-operation")
  57. console.log($this)
  58. // 全部展开
  59. if ($this.hasClass("unfold-all")) {
  60. unfoldAll()
  61. $this.removeClass("unfold-all font-unfold")
  62. .addClass("fold-all font-fold")
  63. .html("&nbsp;&nbsp;全部折叠")
  64. return
  65. }
  66. // 折叠
  67. foldAll()
  68. $this.removeClass("fold-all font-fold")
  69. .addClass("unfold-all font-unfold")
  70. .html("&nbsp;&nbsp;全部展开")
  71. })
  72. })
  73.  
  74. function unfoldAll() {
  75. $(".iteration_gird #div_tabs #member_content .member_area .font-unfold").trigger("click")
  76. // .each(function(idx, elem) {
  77. // console.log(elem)
  78. // const code = $(elem).attr("onclick").replace(")", ").bind(elem)()")
  79. // eval(code)
  80. // })
  81. }
  82.  
  83. function foldAll() {
  84. $(".iteration_gird #div_tabs #member_content .member_area .font-fold").trigger("click")
  85. }
  86. })(window.jQuery);

QingJ © 2025

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