Greasy Fork is available in English.

HideMyName Free Proxy exporter (JSON)

Export proxies from HideMyName into a JSON file. Premium membership NOT required.

// ==UserScript==
// @name         HideMyName Free Proxy exporter (JSON)
// @namespace    org.thorlancaster.hidemynameexporter
// @version      1.0
// @description  Export proxies from HideMyName into a JSON file. Premium membership NOT required.
// @author       Thor Lancaster
// @match        https://hidemy.name/en/proxy-list/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var helpText =
        "<ol style='list-style: initial'><li>Use the site to generate a list of proxies you want</li>"+
        "<li>Click \"Add this page\" button for each page of proxies</li>"+
        "<li>When finished, click \"Export JSON\"</li><li>Remember to clear pages when done to prevent old, possibly expired proxies.</li></ol>";
    // Utility Functions
    var DGE = function(name){
        return document.getElementById(name);
    }
    var DCE = function(name){
        return document.createElement(name);
    }
    // UI functions
    // Show a modal message box
    var showMessageBox = function(titleTxt, txt){
        var root = DCE("div");
        var rs = root.style;
        root.id = "fpe-alert";
        rs.position = "fixed";
        rs.zIndex = "9999999";
        rs.width = "100%";
        rs.height = "100%";
        rs.top = "0px";
        rs.left = "0px";
        rs.background = "#0A2132";
        rs.color = "#FFF";
        rs.fontSize = "1.2em";
        var title = DCE("div");
        title.innerHTML = titleTxt;
        var ts = title.style;
        ts.fontSize = "1.5em";
        ts.padding = "0.5em";
        root.appendChild(title);
        var msg = DCE("div");
        msg.innerHTML = txt;
        var mss = msg.style;
        mss.padding = "2%";
        mss.border = "1px solid #777";
        mss.width = "95%";
        mss.maxHeight = "90%";
        mss.maxHeight = "calc(100% - 6rem)";
        mss.overflowY = "auto";
        root.appendChild(msg);
        var exit = DCE("button");
        var bts = exit.style;
        bts.position = "fixed";
        bts.bottom = "0px";
        bts.color = "#000";
        bts.background = "#1CD798";
        bts.padding = "0.5em";
        bts.borderRadius = "0.2rem";
        bts.border = "none";
        bts.fontSize = "1.1rem";
        exit.innerText = "Back to site";
        exit.onclick = function(){
            DGE("fpe-alert").parentElement.removeChild(DGE("fpe-alert"));
        }
        root.appendChild(exit);
        document.body.appendChild(root);
    }
    // Create and return the UI element
    var createUIPane = function(){
        var root = DCE("div");
        var rs = root.style;
        rs.position = "fixed";
        rs.bottom = "0px";
        rs.width = "10rem";
        rs.borderRadius = "0.5rem";
        rs.background = "#0A2132";
        rs.color = "#FFF";
        rs.textAlign = "center";
        ////////
        var title = DCE("div");
        title.innerHTML = "JSON Proxy<br/>Exporter<br/>";
        var ts = title.style;
        ts.fontSize = "1.5em";
        ts.padding = "0.3em";
        ts.background = "#FF9204";
        ts.borderTopLeftRadius = ts.borderTopRightRadius = "0.5rem";
        root.appendChild(title);
        ////////
        var status = DCE("div");
        status.id = "fpe-status";
        var ss = status.style;
        ss.display = "none";
        ss.position = "absolute";
        ss.top = "2rem";
        ss.left = "10rem";
        ss.width = "10rem";
        ss.minHeight = "3rem";
        ss.borderRadius = "0.5em";
        ss.background = "#0A2132";
        root.appendChild(status);
        ////////
        for(var x = 0; x < 4; x++){
            var txt = "Button " + x;
            if(x == 0) txt = "Add this page";
            if(x == 1) txt = "Clear pages";
            if(x == 2) txt = "Export JSON";
            if(x == 3) txt = "How to use";
            var btn = DCE("button");
            var bts = btn.style;
            bts.color = "#000";
            bts.padding = "0.5em";
            bts.borderRadius = "0.2rem";
            bts.border = "none";
            bts.fontSize = "1.1rem";
            if(x == 3){
                bts.fontSize = "0.8rem";
            }
            if(x == 2) { // Emphasized
                bts.background = "#1CD798";
                btn.nNmBg = "#1CD798";
                btn.nHvBg = "#15AE7A";
            } else { // Normal
                bts.background = "#1C98D7";
                btn.nNmBg = "#1C98D7";
                btn.nHvBg = "#157AAE";
            }
            btn.dataset.btnNum = x;
            btn.onmouseover = function(){this.style.background = this.nHvBg;}
            btn.onmouseout = function(){this.style.background = this.nNmBg;}
            btn.onclick = onButtonClick;
            var bdiv = DCE("div");
            var bs = bdiv.style;
            bs.height = "3rem";
            bs.display = "flex";
            bs.alignItems = "center";
            bs.justifyContent = "center";
            btn.innerHTML = txt;
            bdiv.appendChild(btn);
            root.appendChild(bdiv);
        }
        return root;
    }
    var stTimer = null;
    var setStatusText = function(stTxt){
        clearTimeout(stTimer);
        stTimer = setTimeout(function(){
            DGE("fpe-status").style.display = "none";
        }, 2200);
        var el = DGE("fpe-status");
        el.style.display = "block";
        el.innerHTML = stTxt;
    }
    var onButtonClick = function(){
        var num = this.dataset.btnNum;
        if(num == 0){
            addThisPage();
        } else if(num == 1){
            clearPages();
        } else if(num == 2){
            exportJSON();
        } else if(num == 3){
            showHelp();
        }
    }
    // Data parsing functions
    var addThisPage = function(){
        var fpeDatabase = fpeDatabase = JSON.parse(sessionStorage.getItem("fpe-database"));
        if(fpeDatabase == null){
            fpeDatabase = {};
        }
        //////////////// BEGIN DATA SCRAPING
        var table = document.getElementsByClassName("table_block")[0].getElementsByTagName("table")[0];
        var rows = table.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
        for(var x = 0; x < rows.length; x++){
            var row = rows[x];
            var tds = row.getElementsByTagName("td");
            var ip = tds[0].innerText;
            var value = {};
            value.port = tds[1].innerText;
            value.location = tds[2].innerText;
            value.speed = tds[3].innerText;
            value.type = tds[4].innerText.toUpperCase();
            value.anonymity = tds[5].innerText.toUpperCase();

            Object.defineProperty(fpeDatabase, ip, {
                value: value,
                writable: true,
                enumerable: true
            });
        }
        //////////////// END DATA SCRAPING
        sessionStorage.setItem("fpe-database", JSON.stringify(fpeDatabase));
    }
    var clearPages = function(){
        sessionStorage.removeItem("fpe-database");
    }
    var exportJSON = function(){
        var fpeDatabase = JSON.parse(sessionStorage.getItem("fpe-database"));
        if(fpeDatabase != null){
            showMessageBox("JSON Output", "<pre>" + JSON.stringify(fpeDatabase, undefined, 2) + "</pre>");
        } else {
            setStatusText("No data yet. Add some pages first.");
        }
    }
    var showHelp = function(){
        showMessageBox("How to use", helpText);
    }
    // Main function
    var init = function(){
        var ui = createUIPane();
        document.body.appendChild(ui);
    }
    init();
})();