View Single Post
  #7  
Old 16.06.2019, 13:05
thecoder2012's Avatar
thecoder2012 thecoder2012 is offline
Official 9kw.eu Support
 
Join Date: Feb 2013
Location: Internet
Posts: 1,294
Default

Quote:
Originally Posted by Jiaz View Post
You and everyone else is free to create an extension/addon/eventscripter script
Okay.

Example:
Spoiler:
Code:
//Proxylist updates
//disablePermissionChecks();
//setNotifyOnException(true);


var proxy_test = 0;//1=ON,0=OFF
var max_proxies = 0;//0=Unlimited
var old_proxylist = [];
var new_proxylist = "";
var add_proxy = JSON.parse("{\"proxy\" : {\"username\" : null,\"password\" : null,\"port\" : 80,\"address\" : null,\"type\" : \"NONE\",\"preferNativeImplementation\" : false,\"resolveHostName\" : false,\"connectMethodPrefered\" : false},\"rangeRequestsSupported\" : true,\"filter\" : null,\"pac\" : false,\"reconnectSupported\" : false,\"enabled\" : true}");
var filter = new Array();

var settings = "org.jdownloader.updatev2.InternetConnectionSettings";
var storage = "cfg/org.jdownloader.settings.InternetConnectionSettings";
old_proxylist = callAPI("config", "get", settings, storage, "customproxylist");

var html = getPage("https"+"://raw.githubusercontent.com/fate0/proxylist/master/proxy.list");
var lines = html.split("\n");

for (var key in old_proxylist) {
    if (old_proxylist.hasOwnProperty(key)) {
        if (old_proxylist[key].proxy.type == "DIRECT" || old_proxylist[key].proxy.type == "NONE" || old_proxylist[key].enabled == false) {
            if (new_proxylist == "") {
                new_proxylist += JSON.stringify(old_proxylist[key]);
            } else {
                new_proxylist += "," + JSON.stringify(old_proxylist[key]);
            }
        }
    }
}

var myBr = getBrowser();
for (var i = 0; i < lines.length; ++i) {
    if (IsValidJSONString(lines[i])) {
        var temp_JSON = JSON.parse(lines[i]);
        var add_proxy_new = add_proxy;
        add_proxy_new.proxy.type = temp_JSON.type.toUpperCase();
        add_proxy_new.proxy.port = temp_JSON.port;
        add_proxy_new.proxy.address = temp_JSON.host;

        var errorcheck = 0;
        if (proxy_test == 1) {
            myBr.setProxy(temp_JSON.type + "://" + temp_JSON.host + ":" + temp_JSON.port);
            try {
                myBr.getPage("http://www.google.de/");
            } catch (e) {
                errorcheck = 1;
            }
        }

        if (errorcheck == 0 && proxy_test == 1 || proxy_test != 1) {

            if (add_proxy_new.proxy.address && filter[temp_JSON.host] != true) {
                filter[temp_JSON.host] = true;
                if (new_proxylist == "") {
                    new_proxylist += JSON.stringify(add_proxy_new);
                } else {
                    new_proxylist += "," + JSON.stringify(add_proxy_new);
                }
            }
        }
    }
    if (i >= max_proxies && max_proxies > 0) {
        break;
    }
}
callAPI("config", "set", settings, storage, "customproxylist", "[" + new_proxylist + "]");

function IsValidJSONString(str) {
    if (typeof str !== "string") {
        return false;
    }
    try {
        JSON.parse(str);
    } catch (e) {
        return false;
    }
    return true;
}

Example for Zippyshare with filters in this (german) thread Proxys für Zippyshare funktionieren nicht
__________________
Join 9kw.eu Captcha Service now and let your JD continue downloads while you sleep.

Last edited by thecoder2012; 31.01.2020 at 01:44.
Reply With Quote