-
Notifications
You must be signed in to change notification settings - Fork 0
/
JSUtil.java
37 lines (28 loc) · 1.73 KB
/
JSUtil.java
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
package webwx.util;
import blade.kit.logging.Logger;
import blade.kit.logging.LoggerFactory;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class JSUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(JSUtil.class);
private static String eval(String script) {
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine se = sem.getEngineByName("javascript");
String res = "";
try {
res = String.valueOf(se.eval(script));
} catch (ScriptException e) {
e.printStackTrace();
}
return res;
}
public static String getPushServer(String host) {
String pushServer = JSUtil.eval(" var e = '" + host + "',\n" +
" t = 'weixin.qq.com',\n" +
" o = 'file.wx.qq.com',\n" +
" n = 'webpush.weixin.qq.com';\n" +
" e.indexOf('wx2.qq.com') > -1 ? (t = 'weixin.qq.com', o = 'file2.wx.qq.com', n = 'webpush2.weixin.qq.com') : e.indexOf('qq.com') > -1 ? (t = 'weixin.qq.com', o = 'file.wx.qq.com', n = 'webpush.weixin.qq.com') : e.indexOf('web1.wechat.com') > -1 ? (t = 'wechat.com', o = 'file1.wechat.com', n = 'webpush1.wechat.com') : e.indexOf('web2.wechat.com') > -1 ? (t = 'wechat.com', o = 'file2.wechat.com', n = 'webpush2.wechat.com') : e.indexOf('wechat.com') > -1 ? (t = 'wechat.com', o = 'file.wechat.com', n = 'webpush.wechat.com') : e.indexOf('web1.wechatapp.com') > -1 ? (t = 'wechatapp.com', o = 'file1.wechatapp.com', n = 'webpush1.wechatapp.com') : (t = 'wechatapp.com', o = 'file.wechatapp.com', n = 'webpush.wechatapp.com');");
return pushServer;
}
}