TMS_Library

util lib for TMS related scripts

当前为 2024-01-31 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/486123/1320288/TMS_Library.js

  1. // ==UserScript==
  2. // @name TMS_Library
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-01-31#2
  5. // @description util lib for TMS related scripts
  6. // @author bliushtein
  7. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  8. // @grant GM_xmlhttpRequest
  9. // ==/UserScript==
  10. function delay(milliseconds){
  11. return new Promise(resolve => {
  12. setTimeout(resolve, milliseconds);
  13. });
  14. }
  15. function sendRequest(url, method = 'GET', body = null) {
  16. console.log(url, method, body);
  17. return new Promise((resolve, reject) => {
  18. GM_xmlhttpRequest({
  19. method: method,
  20. timeout: 5000,
  21. onerror: reject,
  22. ontimeout: reject,
  23. onload: resolve,
  24. headers: {
  25. Accept: 'application/json',
  26. 'Content-Type': 'application/json',
  27. // If a user agent is not passed - a POST request fails with 403 error
  28. 'User-Agent': 'Any',
  29. },
  30. data: body,
  31. url: url,
  32. });
  33. }).then(response => {
  34. if ([200, 201].indexOf(response.status) !== -1) {
  35. if (response.responseText == null) {
  36. return {};
  37. }
  38. return JSON.parse(response.responseText);
  39. }
  40. throw new Error(response.status + ' ' + response.statusText + ' ' + response.responseText);
  41. });
  42. }
  43.  
  44. async function getIssues(keys, fields = ["timetracking", "components", "issuetype", "labels", "priority", "customfield_10200", "customfield_10201", "customfield_10006", "summary", "status", "issuelinks"]) {
  45. if (keys.length == 0) {
  46. return {issues: []};
  47. }
  48. return await sendRequest(`https://tms.netcracker.com/rest/api/latest/search?jql=issuekey IN (${keys.join(",")})&fields=${fields.join(",")}`);
  49. }
  50.  
  51. async function getSubtasts(keys, fields = ["timetracking", "components", "issuetype", "labels", "status"]) {
  52. if (keys.length == 0) {
  53. return {issues: []};
  54. }
  55. return await sendRequest(`https://tms.netcracker.com/rest/api/latest/search?jql=parent IN (${keys.join(",")})&fields=${fields.join(",")}`);
  56. }

QingJ © 2025

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