微加-网络资源管理-端口数量自动增加

对微加的功能自动化

  1. // ==UserScript==
  2. // @name 微加-网络资源管理-端口数量自动增加
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-02-17
  5. // @description 对微加的功能自动化
  6. // @author Daniel
  7. // @match https://adm.iops.app.sccncd.com/manager/form-pro/management/441468?appid=58&menus=hidden
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=sccncd.com
  9. // @grant none
  10. // @require https://code.jquery.com/jquery-3.6.0.min.js
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // 创建一个按钮元素
  18. const button = document.createElement('button');
  19. button.innerText = '端口数量-自增';
  20. button.style.position = 'fixed';
  21. button.style.top = '15%';
  22. button.style.left = '50%';
  23. button.style.zIndex = 1000;
  24. button.style.padding = '10px 20px';
  25. button.style.backgroundColor = '#007bff';
  26. button.style.color = '#fff';
  27. button.style.border = 'none';
  28. button.style.borderRadius = '5px';
  29. button.style.cursor = 'pointer';
  30. // 将按钮添加到页面上
  31. document.body.appendChild(button);
  32.  
  33. function sleep(ms) {
  34. return new Promise(resolve => setTimeout(resolve, ms));
  35. }
  36. $(document).ready(async function() {
  37. await sleep(2000)
  38.  
  39. // 添加点击事件
  40. button.addEventListener('click', async() => {
  41. for(var i=85;i<145;i++){
  42. // if(i==48){
  43. // i+=1;
  44. // continue;
  45. // }
  46. console.log(i)
  47. //点击新增数据
  48. $('.vj-b0f7898f')[0].click()
  49. await sleep(2000)
  50. // 1. 获取 iframe 元素
  51. const iframe = document.querySelector('.vj-b8673ac6');
  52. //console.log(iframe)
  53. // 3. 访问 iframe 内部的 DOM
  54. const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
  55. const 字段名称 = iframeDoc.querySelectorAll('.vj-db69b794')[0]
  56. 字段名称.focus()
  57. //输入字段名称
  58. 字段名称.value = i+"口";
  59.  
  60. // console.warn("请选择")
  61. // await sleep(5000)
  62. //资源类型下拉框
  63. const input = iframeDoc.querySelectorAll("input.ant-select-selection-search-input")[0]
  64. input.focus();
  65. const mouseDownEvent = new MouseEvent('mousedown', {
  66. bubbles: true,
  67. cancelable: true,
  68. view: window
  69. });
  70. input.dispatchEvent(mouseDownEvent);
  71.  
  72. await sleep(800)
  73. // 找到下拉框的容器
  74. const dropdown = iframeDoc.querySelector('.rc-virtual-list-holder-inner'); // 替换为你的下拉框 class
  75. if (dropdown) {
  76. dropdown.style.display = 'block'; // 显示下拉框
  77. }
  78. await sleep(500)
  79. // 找到下拉框中的选项并点击
  80. const options = dropdown.querySelectorAll('.ant-select-item'); // 替换为你的选项 class
  81. options.forEach(option => {
  82. if (option.textContent.includes('光缆')||option.textContent.includes('数据')) {
  83. option.click(); // 点击匹配的选项
  84. }
  85. });
  86.  
  87.  
  88. await sleep(500)
  89.  
  90.  
  91. //输入序号
  92. const 序号 = iframeDoc.querySelectorAll('.vj-421806a2 input')[0]
  93. 序号.focus()
  94. 序号.value = i+3;
  95. // console.warn("请选择")
  96. // await sleep(6000)
  97. await sleep(1000)
  98. //选择数量下拉框
  99. const input2 = iframeDoc.querySelectorAll("input.ant-select-selection-search-input")[1]
  100. input2.focus();
  101.  
  102. const mouseDownEvent2 = new MouseEvent('mousedown', {
  103. bubbles: true,
  104. cancelable: true,
  105. view: window
  106. });
  107. input2.dispatchEvent(mouseDownEvent2);
  108. await sleep(500)
  109. // 修改输入框的值
  110. const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
  111. window.HTMLInputElement.prototype,
  112. 'value'
  113. ).set;
  114. nativeInputValueSetter.call(input2, i); // 直接修改值
  115.  
  116. // 触发 input 事件
  117. const input2Event = new Event('input', { bubbles: true });
  118. input2.dispatchEvent(input2Event);
  119.  
  120. // 触发 change 事件
  121. const change2Event = new Event('change', { bubbles: true });
  122. input2.dispatchEvent(change2Event);
  123.  
  124. await sleep(500)
  125. // 找到下拉框的容器
  126. const dropdown2 = iframeDoc.querySelectorAll('.rc-virtual-list-holder-inner')[1]; // 替换为你的下拉框 class
  127. if (dropdown2) {
  128. dropdown2.style.display = 'block'; // 显示下拉框
  129. }
  130. await sleep(1000)
  131. // 找到下拉框中的选项并点击
  132. const options2 = dropdown2.querySelectorAll('.ant-select-item'); // 替换为你的选项 class
  133. options2.forEach(option2 => {
  134. if (option2.textContent==i) {
  135. console.log("成功匹配")
  136. option2.click(); // 点击匹配的选项
  137. }
  138. });
  139. await sleep(2000)
  140. //点击提交
  141. iframeDoc.querySelectorAll('.vj-e471ba46')[1].click()
  142. await sleep(3500)
  143. }
  144.  
  145. });
  146. })
  147. })();

QingJ © 2025

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