function initProcess(){ $(".progress").css({"height":"2rem","font-size":"1.5rem","border-radius":"0.25rem"}); $("#progressbar1").attr("aria-valuenow", 0).css("width", 0 + "%").text(""); $("#progressbar2").attr("aria-valuenow", 0).css("width", 0 + "%").text("").css({"background-color":"#005f99"}); $("#result-wait-1").css('display', 'none'); $("#result-wait-2").css('display', 'none'); $("#result-wait-4").css('display', 'none'); $("#result-wait-3").css('display', 'none'); $("#result-wait-5").css('display', 'block'); $("#result-wait-6").css('display', 'none'); $("#result-wait-7").css('display', 'none'); } function show_model(kdata,title,ext,note){ downloadTitle = title; downloadUrl[ext][note] = kdata.downloadUrlX; $("#de-loader").css('display', 'none'); $("#result-wait").css('display', 'none'); $("#myModalLabel").text(title); $('#myModal').modal('show'); try { // show ads if ( open_ads == "1") { $("#A_downloadUrl").attr("target", "_blank"); var href_prefix = lang == 'en' ? "/" : ("/" + lang + "/"); $("#A_downloadUrl").attr("href", "https://s.ssstiktok.ws"+ href_prefix +"?url=" + kdata.downloadUrlX + "&ref=" + window.location.href ); } else { $("#A_downloadUrl").attr("href", kdata.downloadUrlX); } } catch (e) { $("#A_downloadUrl").attr("href", kdata.downloadUrlX); console.log(e) } return; var a = Math.random(); var adurl; if (a < 1) { adurl = "https://chatgpt.www-2048.com?ext=" + encodeURIComponent(ext) + "&title=" + encodeURIComponent(title) + "&url=" + encodeURIComponent(kdata.downloadUrlX) + "&dd=1"; } else{ adurl = "https://chatgpt.www-2048.com?ext=" + encodeURIComponent(ext) + "&title=" + encodeURIComponent(title) + "&url=" + encodeURIComponent(kdata.downloadUrlX) + "&dd=1"; } if (isWindowOpenUrl(adurl)) { return; } else { if (Math.random() < 1) { $("#myModalLabel").text(title); $('#myModal').modal('show'); $("#A_downloadUrl").attr("target", "_blank"); $("#A_downloadUrl").click(function () { $('#myModal').modal('hide'); }) $("#A_downloadUrl").attr("href", adurl); } else { $("#myModalLabel").text(title); $('#myModal').modal('show'); $("#A_downloadUrl").attr("href", kdata.downloadUrlX); } } } function downloadStatus(url, title, id, ext, totalSize, note, format, countP) { if (countP != count || status_stop) { return; } if (!downloadUrl[ext][note]) { $.ajax({ type: "POST", url: getStatusHost(id), headers: { "x-note": note }, data: { platform: "youtube", url: url, title: title, id: id, ext: ext, note: note, format: format, }, dataType: "json", success: function (kdata) { if (countP == count) { if (downloadUrl[ext][note]) { d_busy = false;// by timer return; } if (kdata.status == 'success') { show_model(kdata,title,ext,note); d_busy = false; } else if (kdata.status == 'convert_ready') { setTimeout(function () { download(url, title, id, ext, totalSize, note, format, countP); }, 20000) } else if (kdata.status == 'processing') { setTimeout(function () { downloadStatus(url, title, id, ext, totalSize, note, format, countP); }, 4000) if(kdata["type"] != undefined && kdata["type"]=="downloading" ){ if (kdata.percent != undefined) { var p = parseInt(kdata.percent.substr(0, kdata.percent.length - 1)); var nowP = $("#progressbar1").attr("aria-valuenow"); if (p > nowP) { $("#progressbar1").attr("aria-valuenow", p); $("#progressbar1").css("width", p + "%"); $("#progressbar1").text(p + "%"); } } $("#result-wait-1").css('display', 'block'); $("#result-wait-5").css('display', 'none'); $("#result-wait-6").css('display', 'none'); $("#result-wait-7").css('display', 'none'); } if(kdata["type"] != undefined && kdata["type"]=="converting"){ $("#result-wait-1").css('display', 'none'); if(note == "mp3-128k" || note == "mp3-320k"){ $("#result-wait-4").css('display', 'block'); }else{ $("#result-wait-2").css('display', 'block'); } $("#result-wait-3").css('display', 'none'); $("#result-wait-5").css('display', 'none'); $("#result-wait-6").css('display', 'none'); $("#result-wait-7").css('display', 'none'); if (kdata.percent != undefined) { var p = parseInt(kdata.percent.substr(0, kdata.percent.length - 1)); var nowP = $("#progressbar2").attr("aria-valuenow"); $("#progressbar1").attr("aria-valuenow", 100); $("#progressbar1").css("width", 100-p + "%"); $("#progressbar1").text(""); if (p > nowP) { $("#progressbar2").attr("aria-valuenow", p); $("#progressbar2").css("width", p + "%"); $("#progressbar2").text(p + "%"); } } } if(kdata["type"] != undefined && kdata["type"]=="merging"){ $("#progressbar1").attr("aria-valuenow", 100); $("#progressbar1").css("width", 0 + "%"); $("#progressbar1").text(""); $("#progressbar2").attr("aria-valuenow", 100); $("#progressbar2").css("width", 100 + "%"); $("#progressbar2").text(100 + "%"); $("#result-wait-1").css('display', 'none'); $("#result-wait-2").css('display', 'none'); $("#result-wait-4").css('display', 'none'); $("#result-wait-5").css('display', 'none'); $("#result-wait-6").css('display', 'none'); $("#result-wait-7").css('display', 'none'); $("#result-wait-3").css('display', 'block'); } if (kdata["type"] != undefined && kdata["type"]=='analyse_start'){ console.log(kdata["type"]) $("#result-wait-1").css('display', 'none'); $("#result-wait-2").css('display', 'none'); $("#result-wait-3").css('display', 'none'); $("#result-wait-4").css('display', 'none'); $("#result-wait-6").css('display', 'none'); $("#result-wait-7").css('display', 'none'); $("#result-wait-5").css('display', 'block'); } if (kdata["type"] != undefined && kdata["type"]=='retry_analyse_start'){ console.log(kdata["type"]) $("#result-wait-1").css('display', 'none'); $("#result-wait-2").css('display', 'none'); $("#result-wait-3").css('display', 'none'); $("#result-wait-4").css('display', 'none'); $("#result-wait-5").css('display', 'none'); $("#result-wait-7").css('display', 'none'); $("#result-wait-6").css('display', 'block'); } if (kdata["type"] != undefined && kdata["type"]=='download_start'){ console.log(kdata["type"]) $("#result-wait-1").css('display', 'none'); $("#result-wait-2").css('display', 'none'); $("#result-wait-3").css('display', 'none'); $("#result-wait-4").css('display', 'none'); $("#result-wait-5").css('display', 'none'); $("#result-wait-6").css('display', 'none'); $("#result-wait-7").css('display', 'block'); } }else { showDownloadErrorModal("Some errors occurred during conversion, try again or use another link") } } }, error() { if (countP == count) { // showDownloadErrorModal("Some errors occurred during conversion, try again or use another link") d_busy = false; } } }); } } function download(url, title, id, ext, totalSize, note, format, countP) { console.log("count", countP); if (document.querySelector('#convert') !== null) { document.querySelector('#convert').scrollIntoView({ behavior: 'smooth' }); } if (countP !== undefined && countP !== count) { return; } if (!downloadUrl[ext][note] && !d_busy) { if (countP == undefined) { countP = count; } d_busy = true; status_stop = false; $.ajax({ type: "POST", headers: { "x-note": note }, url: getDownloadHost(id), data: { platform: "youtube", url: url, title: title, id: id, ext: ext, note: note, format: format }, dataType: "json", beforeSend: function () { initProcess() $("#de-loader").css('display', 'inline'); $("#result-wait").css('display', 'inline'); setTimeout(function () { downloadStatus(url, title, id, ext, totalSize, note, format, countP); }, 4000) }, success: function (kdata) { if (countP == count) { d_busy = false; if (downloadUrl[ext][note]) { // by timer return; } if (kdata.status == 'success') { show_model(kdata,title,ext,note) if (document.querySelector('#convert') !== null) { document.querySelector('#convert').scrollIntoView({ behavior: 'smooth' }); } } else if (kdata.status == 'convert_ready') { setTimeout(function () { download(url, title, id, ext, totalSize, note, format, countP); }, 20000) }else if (kdata.status == 'busy') { status_stop = true; showDownloadErrorModal("Service is busy, Please try again later!") }else if (kdata.status == 'country_error' || kdata.status == 'unsupported_url') { status_stop = true; showDownloadErrorModal("Not support this link, please use another link!") } else if (kdata.status == 'live_error') { status_stop = true; showDownloadErrorModal("The live broadcast has just ended. You need to wait 3-7 days before downloading") } else if (kdata.status == 'sign_in_error' || kdata.status == 'timed_out_error' || kdata.status == 'not_response') { status_stop = true; showDownloadErrorModal("Some errors occurred during conversion, please try again!") } else { status_stop = true; showDownloadErrorModal("Some errors occurred during conversion, try again or use another link!") } } }, error() { if (countP == count) { d_busy = false; status_stop = true; showDownloadErrorModal("Some errors occurred during conversion, try again or use another link!") } } }); } else { if (downloadUrl[ext][note]) { $("#myModalLabel").text(downloadTitle); $('#myModal').modal('show'); // $("#A_downloadUrl").attr("href", downloadUrl[ext][note]); $("#A_downloadUrl").attr("href", "https://s.ssstiktok.ws/?url=" + downloadUrl[ext][note] + "&ref=" + window.location.href ); } } } function showDownloadErrorModal(errorMsg){ $("#de-loader").css('display', 'none'); $("#result-wait").css('display', 'none'); $("#downloadErrorLabel").html("Online download service error, You can try again or use iflydown video downloader to download.") // $("#downloadErrorLabel").text(errorMsg); $('#downloadErrorModal').modal('show'); } function isWindowOpenUrl(url) { let isBlocked = false try { let popup = window.open(url, "_blank"); if (popup == null || typeof (popup) == "undefined") { isBlocked = true } } catch (e) { isBlocked = true } return !isBlocked; } let cftoken = ""; function analyze(retry) { // 禁用按钮 $('#btn-submit').css('pointer-events', "none"); $("#result").empty(); turnstile.render("#captchaContainer", { sitekey: "0x4AAAAAAAzuNQE5IJEnuaAp", // sitekey: "1x00000000000000000000AA", callback: function (token) { cftoken = token setTimeout(()=>{ analyzeReal(retry); $("#captchaContainer").empty() },500) }, errorCallback: function(error) { $('#btn-submit').css('pointer-events', "auto"); $(".dropdown-menu").css('display', 'none'); $("#de-loader").css('display', 'none'); $("#result").empty().append("