Zentao-Fs

禅道与飞书的bug通信

  1. // ==UserScript==
  2. // @name Zentao-Fs
  3. // @namespace https://www.flashmoney.com/
  4. // @version 1.1
  5. // @description 禅道与飞书的bug通信
  6. // @grant GM_addStyle
  7. // @run-at document-end
  8. // @author ll
  9. // @match https://project.flashexpress.pub/zentao/bug-*
  10. // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. const whiteName = ['L:刘丽 前端', 'W:王文君']
  17. const href = window.location.href
  18. console.log(href)
  19. $('body')
  20. .delegate('#submit', 'click', function(event) {
  21. const href = window.location.href
  22.  
  23. if(href.indexOf('bug-create') > -1) {
  24. // 影响版本
  25. const _require = $('#openedBuild_chosen .search-choice >span').text()
  26. // 标题
  27. const _bugTitle = $('.input-control #title').val()
  28. // 指派给
  29. const bugUserName = $("#assignedTo_chosen >.chosen-single-with-deselect >span").text()
  30.  
  31. if (_require && _bugTitle) {
  32. sendMessageFeiShu(_bugTitle, bugUserName)
  33. }
  34. } else {
  35. const _bugUserName = $(".picker-selections .picker-selection-text").text()
  36.  
  37. const _bugTitle = $('.input-control #title').val() || $('.main-header >h2').children().eq(1).text()
  38.  
  39. // 状态置为解决不发送
  40. const _resolution = $('#resolution_chosen')
  41. if (_resolution.length) return
  42.  
  43. sendMessageFeiShu(_bugTitle, _bugUserName)
  44. }
  45. });
  46.  
  47.  
  48.  
  49. // send飞书
  50. function sendMessageFeiShu(_title, _name){
  51. if(!whiteName.includes(_name)) return
  52.  
  53. const query = {
  54. msg_type: "post",
  55. content: {
  56. "post": {
  57. "zh_cn": {
  58. "title": "有人给你提bug",
  59. "content": [
  60. [{
  61. "tag": "text",
  62. "text": 'bug名:'
  63. },
  64. {
  65. "tag": "text",
  66. "text": _title
  67. }],
  68. [{
  69. "tag": "text",
  70. "text": '归属人:'
  71. },
  72. {
  73. "tag": "text",
  74. "text": _name
  75. }]
  76. ]
  77. }
  78. }
  79. }
  80. }
  81. $.ajax({
  82. url:"https://open.feishu.cn/open-apis/bot/v2/hook/02eadbf7-31de-4f4d-bc7e-613ec986ba60",
  83. type: "post",
  84. headers:{'Content-Type':'application/json'},
  85. dataType: 'json',
  86. data: JSON.stringify(query),
  87. success:function(result){
  88. console.log('send success')
  89. }
  90. });
  91.  
  92. }
  93. })();