proxy getter

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         proxy getter
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  从代理表中获取代理 ip:port 列表
// @author       me10zyl
// @match        http://www.proxynova.com/proxy-server-list/*
// @match        http://cn-proxy.com/*
// @match        http://www.kuaidaili.com/*
// @grant        none
// @require      https://code.jquery.com/jquery-1.12.4.min.js
// ==/UserScript==

var selectors = ["#tbl_proxy_list",".table-container", "#index_free_list"];
(function() {

    // Your code here...

    for(var i in selectors){
        if($(selectors[i]).length <= 0){
            continue;
        }
        $(selectors[i]).before("<button id='copy_btn_1234'>复制这些代理地址</button>");
        $("#copy_btn_1234").click(function(){
            catchProxies();
        });
    }

    $(document).keypress(function(e){
        if(e.which == 55){
            catchProxies();
        }
    });
})();

function catchProxies(){
    var ips = [];
    console.log("start fetch proxy ips...");
    for(var i in selectors){
        if($(selectors[i]).length <= 0){
            continue;
        }
        $(selectors[i] + " tr").each(function(){
            var ip = $(this).find("td:first-child").text().trim();
            var port = $(this).find("td:nth-child(2)").text().trim();
            if(!/\s+/.test(port)){
                var str = ip + ":" + port;
                console.log(str);
                ips.push(str);
            }
        });
    }
    var alertstr = "";
    for(var j in ips){
        alertstr += ips[j] + "\n";
    }
    copyToClipboard(alertstr);
}


function copyToClipboard(text){
        window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
}