@@ -125,9 +125,9 @@ function resetForm() {
125
125
$ ( document ) . on ( 'keyup' , '#defConfig' , function ( e ) {
126
126
e . preventDefault ( ) ;
127
127
let config = $ ( this ) . val ( ) . trim ( ) ;
128
+ resetForm ( ) ;
128
129
if ( config === '' ) {
129
130
//console.clear();
130
- resetForm ( ) ;
131
131
return false ;
132
132
}
133
133
let protocol = getProtocol ( config ) ;
@@ -245,19 +245,33 @@ $(document).on('keyup', '#defConfig', function(e) {
245
245
}
246
246
let path = setPath ( protocol !== 'vmess' && defConfig . type === 'ws' || protocol === 'vmess' && defConfig . net === 'ws' ? defConfig . path : "" ) ;
247
247
let early = $ ( '#early' ) . is ( ':checked' ) ;
248
- if ( early && stream === 'ws' ) {
248
+ if ( path . endsWith ( "?ed=2560" ) && ! early ) {
249
+ $ ( '#early' ) . prop ( 'checked' , true ) ;
250
+ }
251
+ else if ( path . endsWith ( "?ed=2048" ) ) {
252
+ path = path . replace ( '?ed=2048' , '?ed=2560' ) ;
253
+ if ( ! early ) {
254
+ $ ( '#early' ) . prop ( 'checked' , true ) ;
255
+ }
256
+ }
257
+ else if ( early && stream === 'ws' ) {
258
+ path = path . replace ( / \? e d = \d + / , '' ) ;
249
259
path = path + '?ed=2560' ;
250
260
}
251
- $ ( '#uuid' ) . val ( getHashId ( defConfig . id ) ) ;
261
+ else {
262
+ path = path . replace ( / \? e d = \d + / , '' ) ;
263
+ $ ( '#early' ) . prop ( 'checked' , false ) ;
264
+ }
252
265
$ ( '#path' ) . val ( path ) ;
266
+ $ ( '#uuid' ) . val ( getHashId ( defConfig . id ) ) ;
253
267
} ) ;
254
268
255
269
function setPath ( string ) {
256
270
if ( typeof string === "undefined" ) {
257
271
string = "" ;
258
272
}
259
273
if ( string . length > 0 ) {
260
- string = string . replace ( '?ed=2048' , '' ) . replace ( '?ed=2560' , '' ) ;
274
+ // string = string.replace('?ed=2048', '').replace('?ed=2560', '');
261
275
/*if (!string.startsWith("/")) {
262
276
string = '/'+string;
263
277
}*/
@@ -289,6 +303,11 @@ $(document).on('click', '#early', function(e) {
289
303
let stream = $ ( '#stream' ) . val ( ) ;
290
304
if ( early && stream === 'ws' ) {
291
305
path = path + '?ed=2560' ;
306
+ $ ( '#early' ) . prop ( 'checked' , true ) ;
307
+ }
308
+ else {
309
+ path = path . replace ( / \? e d = \d + / , '' ) ;
310
+ $ ( '#early' ) . prop ( 'checked' , false ) ;
292
311
}
293
312
$ ( '#path' ) . val ( path ) ;
294
313
} ) ;
0 commit comments