proxy getter

从代理表中获取代理 ip:port 列表

  1. // ==UserScript==
  2. // @name proxy getter
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 从代理表中获取代理 ip:port 列表
  6. // @author me10zyl
  7. // @match http://www.proxynova.com/proxy-server-list/*
  8. // @match http://cn-proxy.com/*
  9. // @match http://www.kuaidaili.com/*
  10. // @grant none
  11. // @require https://code.jquery.com/jquery-1.12.4.min.js
  12. // ==/UserScript==
  13.  
  14. var selectors = ["#tbl_proxy_list",".table-container", "#index_free_list"];
  15. (function() {
  16.  
  17. // Your code here...
  18.  
  19. for(var i in selectors){
  20. if($(selectors[i]).length <= 0){
  21. continue;
  22. }
  23. $(selectors[i]).before("<button id='copy_btn_1234'>复制这些代理地址</button>");
  24. $("#copy_btn_1234").click(function(){
  25. catchProxies();
  26. });
  27. }
  28.  
  29. $(document).keypress(function(e){
  30. if(e.which == 55){
  31. catchProxies();
  32. }
  33. });
  34. })();
  35.  
  36. function catchProxies(){
  37. var ips = [];
  38. console.log("start fetch proxy ips...");
  39. for(var i in selectors){
  40. if($(selectors[i]).length <= 0){
  41. continue;
  42. }
  43. $(selectors[i] + " tr").each(function(){
  44. var ip = $(this).find("td:first-child").text().trim();
  45. var port = $(this).find("td:nth-child(2)").text().trim();
  46. if(!/\s+/.test(port)){
  47. var str = ip + ":" + port;
  48. console.log(str);
  49. ips.push(str);
  50. }
  51. });
  52. }
  53. var alertstr = "";
  54. for(var j in ips){
  55. alertstr += ips[j] + "\n";
  56. }
  57. copyToClipboard(alertstr);
  58. }
  59.  
  60.  
  61. function copyToClipboard(text){
  62. window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
  63. }