提取IP端口

test

  1. // ==UserScript==
  2. // @name 提取IP端口
  3. // @namespace
  4. // @version 0.1
  5. // @description test
  6. // @author You
  7. // @license MIT
  8. // @match https://www.zoomeye.org/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 创建按钮元素
  16. const button = document.createElement('button');
  17. button.innerHTML = '提取IP:端口';
  18. button.style.position = 'fixed';
  19. button.style.bottom = '60px';
  20. button.style.right = '20px';
  21. button.style.zIndex = '9999';
  22.  
  23. // 添加按钮到页面
  24. document.body.appendChild(button);
  25.  
  26. // 按钮点击事件处理函数
  27. button.addEventListener('click', function() {
  28. const ipAddresses = [];
  29.  
  30. // 获取所有class为"search-result-item-info"的<div>标签
  31. const searchResultInfos = document.querySelectorAll('div.search-result-item-info');
  32.  
  33. // 遍历所有搜索结果项
  34. for (const info of searchResultInfos) {
  35. // 在每个搜索结果项中查找包含IP和端口信息的<a>标签
  36. const link = info.querySelector('a[href*="http://"]');
  37.  
  38. if (link) {
  39. // 获取链接的href属性值,然后提取出其中的IP和端口信息
  40. const href = link.href;
  41. const match = href.match(/http:\/\/([\d.]+):(\d+)/);
  42. if (match) {
  43. const ip = match[1];
  44. const port = match[2];
  45. const ipAddress = `${ip}:${port}`;
  46. ipAddresses.push(ipAddress);
  47. }
  48. }
  49. }
  50.  
  51. // 复制提取到的IP地址到剪贴板
  52. if (ipAddresses.length > 0) {
  53. const ipAddressesText = ipAddresses.join('\n');
  54. copyToClipboard(ipAddressesText);
  55. }
  56. });
  57.  
  58. // 复制文本到剪贴板
  59. function copyToClipboard(text) {
  60. const textarea = document.createElement('textarea');
  61. textarea.value = text;
  62. textarea.style.position = 'fixed'; // 使元素不可见
  63. document.body.appendChild(textarea);
  64. textarea.select();
  65. document.execCommand('copy');
  66. document.body.removeChild(textarea);
  67. }
  68. })();

QingJ © 2025

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