IP自动查询-批量查询IP-无人值守-站长工具

Automate actions on ip.tool.chinaz.com/ipbatch

  1. // ==UserScript==
  2. // @name IP自动查询-批量查询IP-无人值守-站长工具
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description Automate actions on ip.tool.chinaz.com/ipbatch
  6. // @author simon
  7. // @match https://ip.tool.chinaz.com/ipbatch
  8. // @license MIT
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @grant GM_registerMenuCommand
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Your IP list stored in an array
  18. let ipList = GM_getValue("ipList");
  19. let ipIndex = GM_getValue("ipIndex");
  20. let autoCmd = GM_getValue("autoCmd");
  21. let tableIp = GM_getValue("tableIp");
  22. let onceNum = 100; //单次查询多少个IP
  23. if(tableIp == undefined){
  24. tableIp="";
  25. }
  26. debugger
  27. // Function to set IP addresses in the textarea
  28. function setIPAddresses() {
  29. const textarea = document.getElementById('address');
  30. let ipArray = ipList.split('\n');
  31. var lastIndex = parseInt(ipIndex) +onceNum;
  32. if(ipArray){
  33. var currIP=[];
  34. debugger
  35. for(var i = parseInt(ipIndex);i<ipArray.length&&i<lastIndex;i++){
  36. currIP.push(ipArray[i]);
  37. }
  38. if(currIP.length>0){
  39. textarea.value = currIP.join('\n');
  40. GM_setValue('ipIndex', lastIndex);
  41. return true;
  42. }
  43. }else{
  44. console.log("没有找到IP列表:"+ipList);
  45. }
  46. return false;
  47.  
  48. }
  49.  
  50. // Function to copy table content to clipboard
  51. function copyTableToClipboard() {
  52. debugger
  53. const ipListTable = document.getElementById('ipList');
  54. if (ipListTable) {
  55. tableIp+="\n" + ipListTable.innerText;
  56. GM_setValue("tableIp",tableIp);
  57. } else {
  58. console.log('Table not found.');
  59. }
  60. }
  61.  
  62. function search(){
  63.  
  64. // Clear textarea
  65. const textarea = document.getElementById('address');
  66. textarea.value = '';
  67.  
  68. // Set IP addresses in the textarea
  69. if(setIPAddresses() == false){
  70. return;
  71. }
  72.  
  73. // Click the 'submore' button
  74. const submoreButton = document.getElementById('submore');
  75. if (submoreButton) {
  76. submoreButton.click();
  77. }
  78. }
  79.  
  80. // Wait for the page to load
  81. window.addEventListener('load', function() {
  82. copyTableToClipboard();
  83. if(autoCmd){
  84. setTimeout(function() {
  85. search();
  86. }, 1000);
  87. }
  88. });
  89.  
  90.  
  91.  
  92. // 注册(不可用)菜单
  93. GM_registerMenuCommand('#️⃣ 设置任务', function() {
  94. // 创建 Bootstrap 模态框元素
  95. const modalHtml = `
  96. <div class="modal" id="myModal" tabindex="-1" role="dialog">
  97. <div class="modal-dialog" role="document">
  98. <div class="modal-content">
  99. <div class="modal-header">
  100. <h5 class="modal-title">设置任务</h5>
  101. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  102. <span aria-hidden="true">&times;</span>
  103. </button>
  104. </div>
  105. <div class="modal-body">
  106. <div class="form-group">
  107. <label for="input2">IP列表(一行一个)</label>
  108. <textarea id="iplist" placeholder="IP列表(一行一个)" cols="50">${ipList}</textarea>
  109. </div>
  110. <div class="form-group">
  111. <label for="input2">当前行号</label>
  112. <input type="text" id="ipindex" value="${ipIndex}" class="form-control" placeholder="请输入序号">
  113. </div>
  114. <div class="form-group">
  115. <label for="input2">自动执行(刷新页面后自动执行)</label>
  116. <input type="checkbox" id="autocmd" name="checkbox" ${autoCmd?"checked":""}>
  117. </div>
  118. <div class="form-group">
  119. <label for="input2">执行一次</label>
  120. <button id="btnSearch" class="btn btn-success">执行</button>
  121. </div>
  122. <div class="form-group">
  123. <label for="input2">结果列表</label>
  124. <textarea id="resultlist" placeholder="IP结果列表,可以直接复制到Excel" cols="50">${tableIp}</textarea>
  125. <button id="btnClearResult" class="btn btn-success" >清空</button>
  126. </div>
  127. </div>
  128. <div class="modal-footer">
  129. <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
  130. <button type="button" class="btn btn-primary" id="saveInfo">保存</button>
  131. </div>
  132. </div>
  133. </div>
  134. </div>`;
  135.  
  136. // 获取模态框和输入框元素
  137. let modal = document.getElementById('myModal');
  138. if(modal==null){
  139. // 将模态框添加到页面
  140. document.body.insertAdjacentHTML('beforeend', modalHtml);
  141.  
  142. //重新获取模态框
  143. modal = document.getElementById('myModal');
  144.  
  145. const iplist = document.getElementById('iplist');
  146. const ipindex = document.getElementById('ipindex');
  147. const autocmd = document.getElementById('autocmd');
  148.  
  149. $("#btnSearch").click(function(){
  150. search();
  151. });
  152.  
  153. $("#btnClearResult").click(function(){
  154. tableIp = "";
  155. GM_setValue('tableIp', tableIp);
  156. $("#resultlist").val(tableIp);
  157. });
  158.  
  159. // 监听保存按钮的点击事件
  160. document.getElementById('saveInfo').addEventListener('click', function() {
  161. const iplistValue = iplist.value;
  162. const ipindexValue = ipindex.value;
  163. const autocmdValue = autocmd.checked;
  164. debugger
  165. // 如果用户点击了保存按钮,且输入不为空,就保存序号
  166. if (iplistValue !== '') {
  167. GM_setValue('ipList', iplistValue);
  168. ipList = iplistValue;
  169. }
  170. if (ipindexValue !== '') {
  171. GM_setValue('ipIndex', ipindexValue);
  172. ipIndex=ipindexValue;
  173. }
  174. if (autocmdValue !== '') {
  175. GM_setValue('autoCmd', autocmdValue);
  176. autoCmd=autocmdValue;
  177. }
  178. console.log('设置成功');
  179. // 隐藏模态框
  180. $(modal).modal('hide');
  181. });
  182. }
  183. // 打开模态框
  184. $(modal).modal('show');
  185. });
  186. // 动态添加 Bootstrap CSS 样式文件
  187. const bootstrapCss = document.createElement('link');
  188. bootstrapCss.rel = 'stylesheet';
  189. // bootstrapCss.href = 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css'; // 根据实际路径进行修改
  190. bootstrapCss.href = 'https://cdn.staticfile.org/bootstrap/5.3.1/css/bootstrap.min.css'; // 根据实际路径进行修改
  191.  
  192. document.head.appendChild(bootstrapCss);
  193.  
  194. // 动态添加 jQuery 和 Bootstrap JavaScript 文件
  195. const jQueryScript = document.createElement('script');
  196. // jQueryScript.src = 'https://code.jquery.com/jquery-3.5.1.min.js';
  197. jQueryScript.src = 'https://cdn.staticfile.org/jquery/3.7.0/jquery.min.js';
  198.  
  199. jQueryScript.onload = function() {
  200. const bootstrapJs = document.createElement('script');
  201. // bootstrapJs.src = 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js';
  202. bootstrapJs.src = 'https://cdn.staticfile.org/bootstrap/5.3.1/js/bootstrap.min.js';
  203. document.head.appendChild(bootstrapJs);
  204. };
  205. document.head.appendChild(jQueryScript);
  206.  
  207. })();

QingJ © 2025

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