明略-会议室.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // ==UserScript==
  2. // @name T-明略-会议室预定
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.jianjian.work/hysPC/*
  5. // @match https://www.jianjian.work/index.html
  6. // @match https://www.jianjian.work/pcgroup/purchase.html*
  7. // @grant none
  8. // @version 1.0
  9. // @author -
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js
  11. // @require https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js
  12. // @description 2021/8/19 上午10:55:46
  13. // ==/UserScript==
  14. function isInter(arr1, arr2) {
  15. return !(arr2[1] < arr1[0] || arr2[0] > arr1[1]);
  16. }
  17. function isAnyInter(arr1, arr2) {
  18. for (let arr1Element of arr1) {
  19. if (isInter(arr1Element, arr2)) {
  20. return true
  21. }
  22. }
  23. return false
  24. }
  25. (function () {
  26. let date = '2021-12-15'
  27. let startTime = 10; // 几点
  28. let hours = 1; // 持续几个小时
  29. startTime = startTime * 12
  30. let endTime = startTime + hours * 12
  31. let capacityMin = 4; // 会议室容纳人数最少多少
  32. let capacityMax = 20; // 会议室容纳人数最多多少
  33. console.log("欢迎进入北京明略会议室预定");
  34. if (location.href.startsWith("https://www.jianjian.work/index.html")) {
  35. document.querySelector(".login_btn").click();
  36. }
  37. if (location.href.startsWith("https://www.jianjian.work/pcgroup/purchase.html")) {
  38. location.href = "https://www.jianjian.work/hysPC/index.html#/index/home";
  39. }
  40. if (location.href.startsWith("https://www.jianjian.work/hysPC/")) {
  41. // 获取会议室
  42. let roomUrl = "https://www.jianjian.work/room/base?_=1629341394435";
  43. axios.get(roomUrl)
  44. .then(res => {
  45. res = res.data;
  46. if (!res.success) {
  47. console.log("获取会议室列表异常");
  48. return
  49. }
  50. let states = res.model[88085];
  51. // console.table(states);
  52. _.forEach(states, room => {
  53. let roomId = room.id;
  54. // console.log(`正在查询${roomName}`);
  55. let url = `https://www.jianjian.work/building/${roomId}/rooms?date=${date}&startDate=&endDate=&_=1629339983635`;
  56. axios.get(url)
  57. .then(res => {
  58. res = res.data;
  59. if (!res.success || res.model.rooms.length === 0) {
  60. return
  61. }
  62. let room2 = res.model.rooms;
  63. for (const room2Key of room2) {
  64. if (room2Key.capacity < capacityMin || room2Key.capacity > capacityMax || room2Key.closeInfo != null) {
  65. continue
  66. }
  67. let events = room2Key.events;
  68. if (room2Key.name.startsWith("A")) {
  69. continue
  70. }
  71. let arr_all = []
  72. for (const eventsKey of events) {
  73. arr_all.push([parseInt(eventsKey.durationNew[0]), parseInt(eventsKey.durationNew[1])])
  74. }
  75. if (!isAnyInter(arr_all, [startTime + 1, endTime - 1])) {
  76. console.log(`!!!已找到:${room2Key.name};容纳:${room2Key.capacity}人;标签:${room2Key.tools}`);
  77. }
  78. }
  79. })
  80. })
  81. })
  82. }
  83. })();