Skip to content

Commit 683a2e7

Browse files
committed
earlyData autoDetection
1 parent 46e4c75 commit 683a2e7

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

assets/js/script.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ function resetForm() {
125125
$(document).on('keyup', '#defConfig', function(e) {
126126
e.preventDefault();
127127
let config = $(this).val().trim();
128+
resetForm();
128129
if ( config === '' ) {
129130
//console.clear();
130-
resetForm();
131131
return false;
132132
}
133133
let protocol = getProtocol(config);
@@ -245,19 +245,33 @@ $(document).on('keyup', '#defConfig', function(e) {
245245
}
246246
let path = setPath(protocol !== 'vmess' && defConfig.type === 'ws' || protocol === 'vmess' && defConfig.net === 'ws' ? defConfig.path : "");
247247
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(/\?ed=\d+/, '');
249259
path = path+'?ed=2560';
250260
}
251-
$('#uuid').val(getHashId(defConfig.id));
261+
else {
262+
path = path.replace(/\?ed=\d+/, '');
263+
$('#early').prop('checked', false);
264+
}
252265
$('#path').val(path);
266+
$('#uuid').val(getHashId(defConfig.id));
253267
});
254268

255269
function setPath(string) {
256270
if ( typeof string === "undefined" ) {
257271
string = "";
258272
}
259273
if ( string.length > 0 ) {
260-
string = string.replace('?ed=2048', '').replace('?ed=2560', '');
274+
//string = string.replace('?ed=2048', '').replace('?ed=2560', '');
261275
/*if (!string.startsWith("/")) {
262276
string = '/'+string;
263277
}*/
@@ -289,6 +303,11 @@ $(document).on('click', '#early', function(e) {
289303
let stream = $('#stream').val();
290304
if ( early && stream === 'ws' ) {
291305
path = path+'?ed=2560';
306+
$('#early').prop('checked', true);
307+
}
308+
else {
309+
path = path.replace(/\?ed=\d+/, '');
310+
$('#early').prop('checked', false);
292311
}
293312
$('#path').val(path);
294313
});

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ <h4 class="modal-title dirLeft">QRCode</h4>
285285
<script src="./assets/js/jquery.min.js"></script>
286286
<script src="./assets/js/bootstrap.min.js"></script>
287287
<script src="./assets/js/lang.js?v1.14.4"></script>
288-
<script src="./assets/js/script.js?v1.14.6"></script>
288+
<script src="./assets/js/script.js?v1.15"></script>
289289
<script async defer src="https://buttons.github.io/buttons.js"></script>
290290
</footer>
291291
</div>

0 commit comments

Comments
 (0)