1
1
package com .shuzijun .leetcode .plugin .utils ;
2
2
3
+ import com .intellij .ide .plugins .PluginManagerCore ;
4
+ import com .intellij .openapi .extensions .PluginId ;
5
+ import com .intellij .openapi .util .SystemInfo ;
6
+ import com .intellij .util .io .HttpRequests ;
3
7
import com .shuzijun .leetcode .plugin .model .Config ;
8
+ import com .shuzijun .leetcode .plugin .model .PluginConstant ;
9
+ import org .apache .http .client .utils .URIBuilder ;
4
10
11
+ import java .awt .*;
12
+ import java .net .URI ;
13
+ import java .util .Calendar ;
14
+ import java .util .Locale ;
5
15
import java .util .concurrent .ExecutorService ;
6
16
import java .util .concurrent .Executors ;
7
17
10
20
*/
11
21
public class MTAUtils {
12
22
13
- private static String URL = "http ://pingtcss.qq .com/pingd " ;
14
- private static String SID = "500676642 " ;
15
- private static String SI = getI ( "s" );
23
+ private static String URL = "https ://hm.baidu .com/hm.gif " ;
24
+ private static String SID = "153b08575197a6f136f1fe02dd507c1e " ;
25
+ private static String SI = String . valueOf ( System . currentTimeMillis () / 1000 );
16
26
private static String version = null ;
17
27
private static String userAgent = null ;
18
28
@@ -49,10 +59,9 @@ public ClickTask(Config config, String actionsId) {
49
59
50
60
@ Override
51
61
public void run () {
52
- /* try {
62
+ try {
53
63
if (version == null ) {
54
- version = PluginManager.getPlugin(PluginId.getId(PluginConstant.PLUGIN_ID)).getVersion()
55
- .replace("v", "").replaceAll("-|_", ".");
64
+ version = PluginManagerCore .getPlugin (PluginId .getId (PluginConstant .PLUGIN_ID )).getVersion ();
56
65
}
57
66
if (userAgent == null ) {
58
67
if (SystemInfo .OS_NAME .toUpperCase ().contains ("MAC" )) {
@@ -66,29 +75,34 @@ public void run() {
66
75
Dimension screensize = Toolkit .getDefaultToolkit ().getScreenSize ();
67
76
Calendar calendar = Calendar .getInstance ();
68
77
URI uri = new URIBuilder (URL )
69
- .setParameter("dm", "127.0.0.1")
70
- .setParameter("pvi", config.getId())
71
- .setParameter("si", SI)
72
- .setParameter("url", "/" + actionsId)
73
- .setParameter("arg", "")
74
- .setParameter("ty", "0")
75
- .setParameter("rdm", "")
76
- .setParameter("rurl", "")
77
- .setParameter("rarg", "")
78
- .setParameter("adt", version)
79
- .setParameter("r2", SID)
80
- .setParameter("scr", (int)screensize.getWidth() + "x" + (int)screensize.getHeight())
81
- .setParameter("scl", Toolkit.getDefaultToolkit().getScreenResolution() + "-bit")
82
- .setParameter("lg", Locale.getDefault().toString().replace("_", "-").toLowerCase())
83
- .setParameter("tz", -(calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / 60000 / 60 + "")
84
- .setParameter("ext", "version=2.0.14")
85
- .setParameter("random", System.currentTimeMillis() + "")
78
+ .setParameter ("hca" , config .getId ())
79
+ .setParameter ("cc" , "1" )
80
+ .setParameter ("cf" , version )
81
+ .setParameter ("ck" , "0" )
82
+ .setParameter ("cl" , Toolkit .getDefaultToolkit ().getScreenResolution () + "-bit" )
83
+ .setParameter ("ds" , (int ) screensize .getWidth () + "x" + (int ) screensize .getHeight ())
84
+ .setParameter ("vl" , "" )
85
+ .setParameter ("ep" , "3392,2371" )
86
+ .setParameter ("ep" , "3" )
87
+ .setParameter ("ja" , "0" )
88
+ .setParameter ("ln" , Locale .getDefault ().toString ().replace ("_" , "-" ).toLowerCase ())
89
+ .setParameter ("lo" , "0" )
90
+ .setParameter ("lt" , SI )
91
+ .setParameter ("rnd" , String .valueOf (System .currentTimeMillis () / 1000 ))
92
+ .setParameter ("si" , SID )
93
+ .setParameter ("v" , "1.2.92" )
94
+ .setParameter ("lv" , "2" )
95
+ .setParameter ("sn" , "44949" )
96
+ .setParameter ("r" , "0" )
97
+ .setParameter ("ww" , String .valueOf ((int ) screensize .getWidth ()))
98
+ .setParameter ("u" , "http://leetcode-editor.shuzijun.cn/" + actionsId )
86
99
.build ();
87
-
88
- HttpRequests.request(uri.toURL().toString()).userAgent(userAgent).tryConnect();
100
+ HttpRequests .request (uri .toURL ().toString ()).userAgent (userAgent ).tuner (connection -> {
101
+ connection .addRequestProperty ("Cookie" , "HMACCOUNT=" + config .getId () + ";" + "HMACCOUNT_BFESS" + config .getId ());
102
+ }).tryConnect ();
89
103
90
104
} catch (Exception e ) {
91
- }*/
105
+ }
92
106
}
93
107
}
94
108
}
0 commit comments