Skip to content

Commit

Permalink
امکان کپی کد فراهم شد
Browse files Browse the repository at this point in the history
  • Loading branch information
ircfspace committed Jan 30, 2024
1 parent 41bc960 commit 0f8a456
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 69 deletions.
12 changes: 12 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ img[alt="loader"] {
float: right;
width: 100% !important;
}
.fetchIps button {
width: 50%;
}
.fetchIps button:first-child {
width: calc(100% - 100px);
border-radius: 0 5px 5px 0;
}
.fetchIps button:last-child {
width: 100px;
border-radius: 5px 0 0 5px;
border-right: transparent;
}

.minWidth {
float: right;
Expand Down
160 changes: 93 additions & 67 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const protocols = ["vless", "vmess"];
const ports = ["443", "2053", "2083", "2087", "2096", "8443"];

function parser(protocol, config) {
if ( protocol === 'vmess' ) {
Expand Down Expand Up @@ -99,7 +98,7 @@ function base64Decode(config) {
}

$(document).on('click', '#checkConf', function(e) {
$('#defConfig').trigger('keyup')
$('#defConfig').trigger('keyup');
});

function resetForm() {
Expand Down Expand Up @@ -247,74 +246,101 @@ function cleanUrl(url) {
return randomizeCase(finalUrl);
}

function generateJson() {
return new Promise((resolve, reject) => {
let protocol = $('#protocol').val();
//let network = $('#network').val();
let uuid = $('#uuid').val();
let sni = cleanUrl($('#sni').val());
let port = $('#port').val();
let path = setPath($('#path').val());
let tls = $('#tls').is(':checked');
let mux = $('#mux').is(':checked');
let concurrency = $('#concurrency').val();
let packets = $('#packets').val();
let length = $('#length').val();
let interval = $('#interval').val();
//let early = $('#early').is(':checked');
let cleanIp = $('#cleanIp').val();
if ( cleanIp === '' ) {
cleanIp = 'zula.ir';
}
if ( uuid === '' || sni === ''|| port === '' ) {
alert('فرم را تکمیل نمایید.');
return false;
}
fetch('fragment.json?v1.1')
.then(response => response.json())
.then(data => {
data.outbounds[0].protocol = protocol;
if ( mux ) {
data.outbounds[0].mux.enabled = true;
data.outbounds[0].mux.concurrency = Number(concurrency);
}
else {
data.outbounds[0].mux.enabled = false;
data.outbounds[0].mux.concurrency = Number(-1);
}
data.outbounds[0].streamSettings.network = "ws";
data.outbounds[0].streamSettings.tlsSettings.serverName = sni;
data.outbounds[0].streamSettings.wsSettings.headers.Host = sni;
data.outbounds[0].streamSettings.wsSettings.path = path;
data.outbounds[0].settings.vnext[0].port = Number(port);
data.outbounds[0].settings.vnext[0].users[0].id = uuid;
data.outbounds[0].settings.vnext[0].address = cleanIp;
data.outbounds[1].settings.fragment.packets = packets;
data.outbounds[1].settings.fragment.length = length;
data.outbounds[1].settings.fragment.interval = interval;
if ( tls ) {
data.outbounds[0].streamSettings.security = "tls";
}
else {
delete data.outbounds[0].streamSettings.tlsSettings;
delete data.outbounds[0].streamSettings.security;
}
resolve(data);
})
.catch(error => {
reject(error);
});
});
}

$(document).on('click', '#getFile', function(e) {
e.preventDefault();
let protocol = $('#protocol').val();
//let network = $('#network').val();
let uuid = $('#uuid').val();
let sni = cleanUrl($('#sni').val());
let port = $('#port').val();
let path = setPath($('#path').val());
let tls = $('#tls').is(':checked');
let mux = $('#mux').is(':checked');
let concurrency = $('#concurrency').val();
let packets = $('#packets').val();
let length = $('#length').val();
let interval = $('#interval').val();
//let early = $('#early').is(':checked');
let cleanIp = $('#cleanIp').val();
if ( cleanIp === '' ) {
cleanIp = 'zula.ir';
}
if ( uuid === '' || sni === ''|| port === '' ) {
alert('فرم را تکمیل نمایید.');
return;
}
fetch('fragment.json?v1.0')
.then(response => response.json())
generateJson()
.then(data => {
data.outbounds[0].protocol = protocol;
if ( mux ) {
data.outbounds[0].mux.enabled = true;
data.outbounds[0].mux.concurrency = Number(concurrency);
}
else {
data.outbounds[0].mux.enabled = false;
data.outbounds[0].mux.concurrency = Number(-1);
}
data.outbounds[0].streamSettings.network = "ws";
data.outbounds[0].streamSettings.tlsSettings.serverName = sni;
data.outbounds[0].streamSettings.wsSettings.headers.Host = sni;
data.outbounds[0].streamSettings.wsSettings.path = path;
data.outbounds[0].settings.vnext[0].port = Number(port);
data.outbounds[0].settings.vnext[0].users[0].id = uuid;
data.outbounds[0].settings.vnext[0].address = cleanIp;
data.outbounds[1].settings.fragment.packets = packets;
data.outbounds[1].settings.fragment.length = length;
data.outbounds[1].settings.fragment.interval = interval;
if ( tls ) {
data.outbounds[0].streamSettings.security = "tls";
}
else {
delete data.outbounds[0].streamSettings.tlsSettings;
delete data.outbounds[0].streamSettings.security;
}
//console.log(data)
downloadJsonFile(data, 'fragment [ircf.space].json');
const jsonData = JSON.stringify(data, null, 2);
const blob = new Blob([jsonData], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'fragment [ircf.space].json';
a.style.display = 'none';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
})
.catch(error => console.error('Error fetching the JSON file:', error));
.catch(error => {
// Handle errors here
console.error(error);
});
});

function downloadJsonFile(data, filename) {
const jsonData = JSON.stringify(data, null, 2);
const blob = new Blob([jsonData], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename || 'data.json';
a.style.display = 'none';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
$(document).on('click', '#copyCode', function(e) {
e.preventDefault();
generateJson()
.then(data => {
data = JSON.stringify(data, null, 2)
navigator.clipboard.writeText(data).then(() => {
alert('کد در کلیپ‌بورد کپی شد.');
}).catch(() => {
//alert('مشکلی پیش آمده است!');
});
})
.catch(error => {
// Handle errors here
console.error(error);
});
});
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<link href="./assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="./assets/css/bootstrap-rtl.min.css" rel="stylesheet" />
<link href="./assets/css/vazir.css" rel="stylesheet" />
<link href="./assets/css/style.css?v1.5.9" rel="stylesheet" />
<link href="./assets/css/style.css?v1.6" rel="stylesheet" />
<title>IRCF | ابزار فرگمنت</title>
<meta name="description" content="آی پی سالم و تمیز برای کلودفلر (کلادفلر) جهت دسترسی به اینترنت آزاد" />
<meta name="keywords" content="کلودفلر, کلادفلر, cloudflare, cf, آی پی تمیز, آی پی سالم, اسکن آی پی" />
Expand Down Expand Up @@ -108,6 +108,9 @@ <h1>اینترنت برای همه؛ یا هیچ‌کس!</h1>
<button class="btn btn-info" type="submit" id="getFile">
ایجاد فایل JSON
</button>
<button class="btn btn-default active" id="copyCode">
کپی کد
</button>
</div>
<div class="clearfix"></div>
<div id="tableResults" class="hidden">
Expand Down Expand Up @@ -188,7 +191,7 @@ <h4 class="modal-title">دونیت</h4>
</div>-->
<script src="./assets/js/jquery.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>
<script src="./assets/js/script.js?v1.5.12"></script>
<script src="./assets/js/script.js?v1.6"></script>
</footer>
</div>
</div>
Expand Down

0 comments on commit 0f8a456

Please sign in to comment.