-
Notifications
You must be signed in to change notification settings - Fork 2
/
RandomProxy.js
67 lines (67 loc) · 1.23 KB
/
RandomProxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
*
* @Name : RandomProxy.js
* @Version : 1.0
* @Programmer : Max
* @Date : 2018-06-25
* @Released under : https://github.com/BaseMax/RandomProxyJs/blob/master/LICENSE
* @Repository : https://github.com/BaseMax/RandomProxyJs
*
**/
;(function(window,document)
{
"use strict";
/**
* @variable link
*
* @goal : link of free API
*
* @return string
**/
//var link="https://api.ronite.com/proxy/";
var link="http://api.ronite.com/proxy/";
/**
* @function get
*
* @goal : get a proxy from API
*
* @return void
**/
var get=function(callback)
{
var http;
if(window.XMLHttpRequest)
{
//XMLHttpRequest(Chrome, Firefox, IE7+, Edge, Safari Opera)
http=new XMLHttpRequest();
}
else
{
//ActiveXObject(IE5 and IE6)
http=new ActiveXObject("Microsoft.XMLHTTP");
}
http.onreadystatechange=function()
{
if(this.readyState == 4 && this.status == 200)
{
var objs=JSON.parse( this.responseText );
callback(objs);
}
//What will happen when a problem occurs?
//such as : 'down server' , 'low speed' or more...
};
http.open("GET",link,true);
http.send();
};
/**
* @struct proxy
*
* @goal : access to public functions
*
* @return struct
**/
window.proxy=
{
get:get,
};
}(window,document));