View Single Post
  #1492  
Old 10.08.2020, 22:18
Karli Karli is offline
Zetta Loader
 
Join Date: Jun 2015
Posts: 192
Default hilfegesuch für ein script

hiho,

ich verwende ein hier vorgestelltes script zum automatischen downloaden von proxys. funzt soweit immer noch super.

ich würde allerdings gerne div. ports dieser proxyliste auf ne blacklist legen, da proxys mit diesen ports sowieso nie erfolgreiche downloads bringen.
vieleicht ähnlich zu der schon vorhandenen country filterliste?

jetzt frag ich mich als programmier-noob, ob mir jemand das script selber pimpen könnte, oder was dazu schreiben könnte?

damit wir nicht immer nach dem script suchen müssen, post ichs hier nochmal rein, wenn ich darf ...
Code:
disablePermissionChecks();
setNotifyOnException(false);
setAdvancedAlert(true);

// Proxylist updates for hosters (e.g. Zippyshare.com)
// Trigger: Interval (e.g. 10000ms)

var refreshtime = "900"; // (e.g. 900s)
var myCountries = ["GB", "DE", "FR"]; //Filterlist for countries
var max_response_time = 2; //1.5 or higher (e.g. 2), 1 is too low
var proxy_test = 0; //1=ON,0=OFF (very slow)
var max_proxies = 0; //0=Unlimited
var standard_filter = " \"filter\" : {\"type\" : \"WHITELIST\",\"entries\" : [ \"hoster 1\", \"hoster 2\"]},"; //\"filter\" : null, 
var add_proxy = JSON.parse("{\"proxy\" : {\"username\" : null,\"password\" : null,\"port\" : 80,\"address\" : null,\"type\" : \"NONE\",\"preferNativeImplementation\" : false,\"resolveHostName\" : false,\"connectMethodPrefered\" : false},\"rangeRequestsSupported\" : true," + standard_filter + "\"pac\" : false,\"reconnectSupported\" : false,\"enabled\" : true}");
var filter = new Array();

var old_proxylist = [];
var new_proxylist = "";

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

if (IsValidname() || IsValidinterval() && ((Math.round(Date.now() / 1000) - getProperty("LastProxyUpdate", true)) >= refreshtime) && !getProperty("updatingProxy", true) || getProperty("updatingProxy", true)) {
    if (!getProperty("updatingProxy", true)) {
        setProperty("LastProxyUpdate", Math.round(Date.now() / 1000), true);
    } else {
        if (getProperty("updatingProxy", true)) {
            setProperty("updatingProxy", false, true);
        }
    }

    var html;
    try {
        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;
                if (myCountries.indexOf(temp_JSON.country) > -1 || temp_JSON.response_time > max_response_time) {
                    continue; //skip proxy
                }
                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 + "]");
    } catch (e) {}
}

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

function IsValidname() {
    try {
        if (name == "Geoblocking: zippy") {
            return true;
        }
    } catch (e) {
        return false;
    }
    return true;
}

function IsValidinterval() {
    try {
        if (interval >= 10000) {
            return true;
        }
    } catch (e) {
        return false;
    }
    return true;
}
vielen thx schon mal für jeden tropfen fremden gehirnschmalzes *g*
Reply With Quote