diff --git a/README.md b/README.md index 97ea747..a4703da 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## ezytel -## Usage: +## Usage 1. Clone the repo @@ -27,3 +27,6 @@ php -S localhost:8000 ``` Now you could open ezytel at your browser `http://localhost:8000` + +## Backstory +This project was developed at a rozblog forum by J[o]King when Google was whitelisted at the 21 iran network outage, I decided to push this project at the 2026 network outage when they opened google.com. [Original Version](https://github.com/Parsa307/ezytel/tree/rozblog-version) I am not affiliated with J[o]King. diff --git a/index.php b/index.php index 43b7ffe..5f1fda3 100644 --- a/index.php +++ b/index.php @@ -4,7 +4,7 @@ if (!file_exists(__DIR__.'/.cache')) mkdir(__DIR__.'/.cache'); if (!file_exists(__DIR__.'/channels.txt')) file_put_contents(__DIR__.'/channels.txt',''); $CHANNELS = file_parse(); - $VERSION = '4'; + $VERSION = '5'; ?>
diff --git a/proxy.php b/proxy.php index 77dddd4..a149d0d 100644 --- a/proxy.php +++ b/proxy.php @@ -16,5 +16,5 @@ http_response_code(400); }else{ header('Content-Type: image/jpeg'); - header('Location: .cache/'.$hash.'.jpg'); + readfile(__DIR__.'/.cache/'.$hash.'.jpg'); } diff --git a/src/script.js b/src/script.js index e7ddaa8..2074318 100644 --- a/src/script.js +++ b/src/script.js @@ -1,53 +1,70 @@ -document.addEventListener("DOMContentLoaded",()=>{ +document.addEventListener("DOMContentLoaded", () => { + // ========== مدیریت دکمه بازگشت گوشی ========== + window.addEventListener("popstate", function (e) { + if (e.state && e.state.channelOpen) { + // برگردوندن نمای لیست کانالها + document.querySelector(".menu_block").classList.remove("menu_block_hide"); + document.querySelector(".main_block").innerHTML = ""; + document.querySelectorAll(".menu_channel_selected").forEach(elm => { + elm.classList.remove("menu_channel_selected"); + }); + // حذف state تا دفعه بعدی دکمه بازگشت از سایت خارج شود + history.replaceState(null, "", window.location.pathname); + } + }); + // register channels actions document.querySelectorAll(".menu_channel_wrapper").forEach(element => { var chid = element.querySelector(".menu_channel_info p").innerText; - element.setAttribute("chid",chid); - element.addEventListener("click",()=>{ + element.setAttribute("chid", chid); + element.addEventListener("click", () => { document.querySelectorAll(".menu_channel_selected").forEach(elm => { elm.classList.remove("menu_channel_selected"); }); element.classList.add("menu_channel_selected"); document.querySelector(".main_block").innerHTML = ""; - load_more(0,chid,null); + load_more(0, chid, null); + // ثبت state در تاریخچه مرورگر + history.pushState({ channelOpen: true, chid: chid }, "", "#" + chid); }); }); + // load channels updates let chnum = 0; document.querySelectorAll(".menu_channel_wrapper").forEach(element => { setTimeout(() => { var XHR = new XMLHttpRequest(); - XHR.open("GET","proxy.php?info="+element.getAttribute("chid"),true); + XHR.open("GET", "proxy.php?info=" + element.getAttribute("chid"), true); XHR.send(); - XHR.onreadystatechange = function() { + XHR.onreadystatechange = function () { if (this.readyState == 4) { - if (this.status == 200){ + if (this.status == 200) { let data = JSON.parse(XHR.responseText); - if ('avatar' in data && data['avatar'] != ''){ + if ('avatar' in data && data['avatar'] != '') { element.querySelector("img").src = data['avatar']; element.querySelector("img").style.opacity = 1; } - if ('name' in data){ + if ('name' in data) { element.querySelector(".menu_channel_info p").innerHTML = data['name']; } - if ('desc' in data){ + if ('desc' in data) { element.querySelector(".menu_channel_info span").innerHTML = data['desc']; } - if ('newmsg' in data && 'datestr' in data){ - element.querySelector(".menu_channel_stats").innerHTML = ''+data['datestr']+'
'+data['newmsg']+''; - if (data['newmsg'] == ''){ + if ('newmsg' in data && 'datestr' in data) { + element.querySelector(".menu_channel_stats").innerHTML = '' + data['datestr'] + '
' + data['newmsg'] + ''; + if (data['newmsg'] == '') { element.classList.add("menu_channel_allread"); } } - if ('date' in data){ - element.setAttribute("dateid",data['date']); + if ('date' in data) { + element.setAttribute("dateid", data['date']); let move = null; document.querySelectorAll(".menu_channel_wrapper").forEach(elem => { if (move == null && parseInt(data['date']) >= parseInt(elem.getAttribute("dateid"))) move = elem; }); - if (move != null) document.querySelector(".menu_block").moveBefore(element,move); + if (move != null) document.querySelector(".menu_block").moveBefore(element, move); } - }else{ + } else { element.querySelector(".menu_channel_info span").innerHTML = "NETWORK ERROR"; } } @@ -55,51 +72,58 @@ document.addEventListener("DOMContentLoaded",()=>{ }, chnum * 1000); chnum++; }); + // register search function - document.querySelector(".tgme_header_search input").addEventListener("keyup",()=>{ + document.querySelector(".tgme_header_search input").addEventListener("keyup", () => { let search = document.querySelector(".tgme_header_search input").value.trim().toLowerCase(); document.querySelectorAll(".menu_channel_wrapper").forEach(element => { - if (search == '' || element.getAttribute("chid").includes(search) || element.querySelector(".menu_channel_info p").innerText.includes(search)){ + if (search == '' || element.getAttribute("chid").includes(search) || element.querySelector(".menu_channel_info p").innerText.includes(search)) { element.style.display = "flex"; - }else{ + } else { element.style.display = "none"; } }); }); }); -function load_more(next,chid,obj) { + +function load_more(next, chid, obj) { var XHR = new XMLHttpRequest(); - XHR.open("GET","proxy.php?next="+next+"&chid="+chid,true); + XHR.open("GET", "proxy.php?next=" + next + "&chid=" + chid, true); document.querySelector(".page_progress_bar").style.display = "block"; XHR.send(); - XHR.onreadystatechange = function() { + XHR.onreadystatechange = function () { if (this.readyState == 4) { document.querySelector(".page_progress_bar").style.display = "none"; - if (this.status == 200){ + if (this.status == 200) { if (obj != null) obj.parentNode.remove(); let height = document.querySelector(".main_block").scrollHeight; document.querySelector(".main_block").innerHTML = XHR.responseText + document.querySelector(".main_block").innerHTML; - if (next == 0){ - document.querySelector(".main_block").scrollTo({top: document.querySelector(".main_block").scrollHeight}); - if (document.querySelector('div[chid="'+chid+'"]')!=null){ - document.querySelector('div[chid="'+chid+'"]').classList.add("menu_channel_allread"); + if (next == 0) { + // ثبت state هنگام باز شدن اولیه کانال + history.pushState({ channelOpen: true, chid: chid }, "", "#" + chid); + + document.querySelector(".main_block").scrollTo({ top: document.querySelector(".main_block").scrollHeight }); + if (document.querySelector('div[chid="' + chid + '"]') != null) { + document.querySelector('div[chid="' + chid + '"]').classList.add("menu_channel_allread"); } document.querySelector(".menu_block").classList.add("menu_block_hide"); - if (document.querySelector(".tgme_header")!=null){ - document.querySelector(".tgme_header").addEventListener("click",()=>{ + if (document.querySelector(".tgme_header") != null) { + document.querySelector(".tgme_header").addEventListener("click", () => { document.querySelector(".menu_block").classList.remove("menu_block_hide"); document.querySelectorAll(".menu_channel_selected").forEach(elm => { elm.classList.remove("menu_channel_selected"); }); document.querySelector(".main_block").innerHTML = ""; + // پاک کردن state هنگام بستن کانال با کلیک روی هدر + history.replaceState(null, "", window.location.pathname); }); } - }else{ - document.querySelector(".main_block").scrollTo({top: height}); + } else { + document.querySelector(".main_block").scrollTo({ top: height }); } - }else{ + } else { alert("something went wrong! try again!"); } } } -} \ No newline at end of file +} diff --git a/src/style.css b/src/style.css index 684d74f..1b15bb5 100644 --- a/src/style.css +++ b/src/style.css @@ -144,7 +144,6 @@ a { } .menu_channel_selected .menu_channel_stats span { background: #4A4A4A !important; - color: #e0e0e0 !important; } .menu_channel_info p{ width: calc(100% - 25px); @@ -1640,7 +1639,7 @@ a.tgme_widget_message_contact_wrap:focus:hover { .tgme_widget_message_reply .tgme_widget_message_author, .tgme_widget_message_reply .tgme_widget_message_text, .tgme_widget_message_reply .tgme_widget_message_metatext { - font-size: 16px; + font-size: 14px; line-height: 20px; margin: -2px 0; white-space: nowrap; @@ -3089,7 +3088,7 @@ a.tgme_channel_join_telegram { } .tgme_widget_message_author, .tgme_widget_message_forwarded_from { - font-size: 16px; + font-size: 14px; line-height: 19px; margin: 1px 0 0; } @@ -3106,15 +3105,15 @@ a.tgme_channel_join_telegram { .tgme_widget_message_text, .tgme_widget_message_poll, .tgme_widget_message_inline_button { - font-size: 16px; + font-size: 14px; line-height: 21px; } .tgme_widget_message_poll_type { - font-size: 18px; + font-size: 13px; margin-top: 0; } .tgme_widget_message_poll_options { - font-size: 18px; + font-size: 14px; min-width: 240px; padding-top: 0; margin-bottom: 10px;