diff --git a/html/index.html b/html/index.html index 0ebdb25..15212b0 100644 --- a/html/index.html +++ b/html/index.html @@ -47,37 +47,7 @@ url = url+'&before='+getget('before'); } -var req = new XMLHttpRequest(); -req.responseType = 'json'; -req.open('GET', url, true); -req.onload = function() { -var jsonResponse = req.response; - - -var titlesx = url.replace("https://www.reddit.com/r/", ""); -titlesx = titlesx.replace("/.json", ""); -document.title = "rdx - A lightweight mobile web client for reddi"; -posts = jsonResponse['data']['children']; - - -for(var item in posts) { -pid = posts[item]['data']; -fill += postbuilder(pid); -} -fill += ''; -document.getElementById('body').innerHTML = fill; - runhsl(); -}; -req.onerror = function () { -document.getElementById('body').innerHTML = '
Can\'t load content!
There can be multiple reasons for this, your browser\'s aggresive privacy settings may be blocking the one call to reddit.com RDX makes. This happens usually when you use a VPM/Proxy and/or a privacy focused browser like Firefox.
Play around with privacy/tracking options or change your browser. If it still doesn\'t work click the feedback link and send me some info.
'; -}; -req.send(null); +makereq(url); } diff --git a/html/search.html b/html/search.html index 4ffcefa..053f567 100644 --- a/html/search.html +++ b/html/search.html @@ -69,34 +69,8 @@ console.log(url); -var req = new XMLHttpRequest(); -req.responseType = 'json'; -req.open('GET', url, true); -req.onload = function() { -var jsonResponse = req.response; - - -var titlesx = url.replace("https://www.reddit.com/r/", ""); -titlesx = titlesx.replace("/.json", ""); -document.title = titlesx; -posts = jsonResponse['data']['children']; - +makereq(url); -for(var item in posts) { -console.log("xx" + item); -pid = posts[item]['data']; -fill += postbuilder(pid); -} -fill += ''; -document.getElementById('body').innerHTML = fill; - runhsl(); -}; -req.send(null); } diff --git a/html/subreddit.html b/html/subreddit.html index afbe5ac..ab0be64 100644 --- a/html/subreddit.html +++ b/html/subreddit.html @@ -48,34 +48,8 @@ url = url+'&before='+getget('before'); } -var req = new XMLHttpRequest(); -req.responseType = 'json'; -req.open('GET', url, true); -req.onload = function() { -var jsonResponse = req.response; - - -var titlesx = url.replace("https://www.reddit.com/r/", ""); -titlesx = titlesx.replace("/.json", ""); -document.title = titlesx; -posts = jsonResponse['data']['children']; - +makereq(url); -for(var item in posts) { -console.log("xx" + item); -pid = posts[item]['data']; -fill += postbuilder(pid); -} -fill += ''; -document.getElementById('body').innerHTML = fill; - runhsl(); -}; -req.send(null); } diff --git a/html/user.html b/html/user.html index 52a8274..10deb10 100644 --- a/html/user.html +++ b/html/user.html @@ -49,34 +49,7 @@ url = url+'&before='+getget('before'); } -var req = new XMLHttpRequest(); -req.responseType = 'json'; -req.open('GET', url, true); -req.onload = function() { -var jsonResponse = req.response; - - -var titlesx = url.replace("https://www.reddit.com/r/", ""); -titlesx = titlesx.replace("/.json", ""); -document.title = titlesx; -posts = jsonResponse['data']['children']; - - -for(var item in posts) { -console.log("xx" + item); -pid = posts[item]['data']; -fill += postbuilder(pid); -} -fill += ''; -document.getElementById('body').innerHTML = fill; - runhsl(); -}; -req.send(null); +makereq(url); } diff --git a/public/functions.js b/public/functions.js index 6468b49..649e66b 100644 --- a/public/functions.js +++ b/public/functions.js @@ -1,7 +1,7 @@ var bmr = ''; // Utility functions [UNIVERSAL] - +var nexturl = ''; var nextseturl = ''; if(JSON.parse(localStorage.getItem("subs")) !== null){ subslisted = ''; subslistedarray = JSON.parse(localStorage.getItem("subs")); subslistedarray.sort(function(a, b) { @@ -41,8 +41,19 @@ document.head.appendChild(le); document.body.style.fontFamily = curfont+', sans-serif'; } } + +var curinfi = localStorage.getItem('curinfi') || false; +if (window.location.href.indexOf("comments.html") == -1) +{ +if(curinfi == "true") { +var style = document.createElement('style'); +style.innerHTML = '.footer, .infotext, .next {display:none !important}'; +document.head.appendChild(style); +} +} toggletheme(); togglefont(); + function toggle(id){ var x = document.getElementsByClassName("show"); for (k = 0; k < x.length; k++) { @@ -62,6 +73,108 @@ document.getElementById("subssearchi").focus(); // handle case of empty input // return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue; //} + +function makereq(url){ +var fill = ''; +var req = new XMLHttpRequest(); +req.responseType = 'json'; +req.open('GET', url, true); +req.onload = function() { +var jsonResponse = req.response; +var titlesx = url.replace("https://www.reddit.com/r/", ""); +titlesx = titlesx.replace("/.json", ""); +document.title = titlesx; +posts = jsonResponse['data']['children']; +for(var item in posts) { +console.log("xx" + item); +pid = posts[item]['data']; +fill += postbuilder(pid); +} +fill += ''; +document.getElementById('body').innerHTML = fill; + runhsl(); + if(curinfi == "true") { + observe(); + } +}; +req.onerror = function () { +document.getElementById('body').innerHTML = '
Can\'t load content!
There can be multiple reasons for this, your browser\'s aggresive privacy settings may be blocking the one call to reddit.com RDX makes. This happens usually when you use a VPM/Proxy and/or a privacy focused browser like Firefox.
Play around with privacy/tracking options or change your browser. If it still doesn\'t work click the feedback link and send me some info.
'; +}; +req.send(null); +} + +function scorllmore() { +const url = nexturl; +let fill = ''; +if(nexturl != '') {console.log(nexturl); } else {return false;} +var req = new XMLHttpRequest(); +req.responseType = 'json'; +req.open('GET', url, true); +req.onload = function() { +var jsonResponse = req.response; +posts = jsonResponse['data']['children']; +for(var item in posts) { +pid = posts[item]['data']; +fill += postbuilder(pid); +} +var curpage = window.location.href.replace(/\&after.*/,''); +if(jsonResponse['data']['after'] != null) { +if(curpage.indexOf("?") === -1) {curpage = curpage+'?a=b';} +history.pushState("", "newtitle", nextseturl); +nextseturl = curpage+'&after='+jsonResponse['data']['after']; +nexturl = url.split('&after')[0]; +nexturl = nexturl+"&after="+jsonResponse['data']['after']; +} +else { +nexturl = ''; +} +document.getElementById('sxpy').innerHTML += fill; +document.getElementById('sentinel').innerHTML = ' '; + runhsl(); +}; +req.onerror = function () { +document.getElementById('sxpy').innerHTML += '
Can\'t load content! Refresh the page or try again later.
'; +nexturl = ''; +}; +req.send(null); +} + +function observe() { +const options = { + root: null, + threshold: 1.0 + }; +cantload = false; + function callback(entries, observer) { + entries.forEach(entry => { + if (entry.isIntersecting) { + if(cantload == false) { + document.getElementById('sentinel').innerHTML = '
Loading more posts..
'; + cantload = true; + setTimeout(() => { + scorllmore(); + cantload = false; + }, 100); + } + } + }); + } + const observer = new IntersectionObserver(callback, options); + const sentinel = document.getElementById('sentinel'); + if (sentinel) { + observer.observe(sentinel); + } +} + + function htmlDecode(input) { var parser = new DOMParser(); var decoded = parser.parseFromString(input, 'text/html'); @@ -100,7 +213,7 @@ xhr.onreadystatechange = function() fillsubs = ''; for (var singlesub in subslist['subreddits'] ) { -console.log(subslist[singlesub]); +//console.log(subslist[singlesub]); fillsubs += ''+subslist['subreddits'][singlesub]['name']+''; } document.getElementById('subslist').innerHTML = fillsubs; @@ -151,14 +264,17 @@ var replacedText = replaceRedditLinks(post["selftext_html"]); returnfpost += '
'+htmlDecode(replacedText)+'
'; } urli = post['url_overridden_by_dest']; -console.log((typeof post['crosspost_parent_list'] !== 'undefined' && post['crosspost_parent_list'].length > 0)); + if((post['crosspost_parent_list'] != null && post['crosspost_parent_list'].length > 0) || (typeof post['crosspost_parent_list'] !== 'undefined' && post['crosspost_parent_list'].length > 0)){ returnfpost += postbuilder(post['crosspost_parent_list'][0]); } else { if(over18 === 'over18') {returnfpost += '';} -if(typeof urli != "undefined"){ returnfpost += '
'+urlpreview(urli,post)+'
Open URL
'; } +if(typeof urli != "undefined" && post['removed_by_category'] == null){ returnfpost += '
'+urlpreview(urli,post)+'
Open URL
'; } +if(post['removed_by_category'] != null) { +returnfpost += 'Removed by '+ post['removed_by_category']; +} if(post['poll_data'] != null){ returnfpost += pollbuilder(post); } @@ -178,16 +294,10 @@ function allown_sfw(){ window.location.reload(); } function preloadImage(im_url) { - // Create a div element to contain the image tag let container = document.createElement('div'); - - // Set the innerHTML of the container with the image tag container.innerHTML = ``; - // Append the container to the document body to trigger loading document.body.appendChild(container); - - // Remove the container after a short delay (you can adjust the delay as needed) setTimeout(function() { document.body.removeChild(container); }, 1); @@ -218,13 +328,14 @@ returnpost = ''; pjmd = postjson['media_metadata']; pjgd= postjson['gallery_data']; const pjmdsorted = {}; - +if(pjgd) { pjgd.items.forEach((item, index) => { const mediaId = item.media_id; if (pjmd.hasOwnProperty(mediaId)) { pjmdsorted[mediaId] = pjmd[mediaId]; } }); +} let g_timgs = '
+ 31 Jan 2023 +
  • NEW: Infinite Scrolling is here. If that's your thing enable it from the settings page.
  • 18 Jan 2023
  • ADDED: New themes and fonts.
  • UPDATED: Click on the first image of a gallery post to open the images in gallery view.
  • diff --git a/public/search.html b/public/search.html index ed34541..61d5fb7 100644 --- a/public/search.html +++ b/public/search.html @@ -107,34 +107,8 @@ console.log(url); -var req = new XMLHttpRequest(); -req.responseType = 'json'; -req.open('GET', url, true); -req.onload = function() { -var jsonResponse = req.response; - - -var titlesx = url.replace("https://www.reddit.com/r/", ""); -titlesx = titlesx.replace("/.json", ""); -document.title = titlesx; -posts = jsonResponse['data']['children']; - +makereq(url); -for(var item in posts) { -console.log("xx" + item); -pid = posts[item]['data']; -fill += postbuilder(pid); -} -fill += ''; -document.getElementById('body').innerHTML = fill; - runhsl(); -}; -req.send(null); } diff --git a/public/settings.html b/public/settings.html index e7cc21d..9c171b2 100644 --- a/public/settings.html +++ b/public/settings.html @@ -32,6 +32,7 @@
  • 20
  • + Enable infinite scrolling (beta): Export Subscriptions:
  • @@ -67,7 +68,11 @@ document.getElementById('outppg').innerHTML = document.getElementById('ppg').value + " (saved)"; } - +const curinfi = localStorage.getItem('curinfi') === "true"; +document.getElementById("infibox").checked = curinfi; +function checkinfi(){ +localStorage.setItem('curinfi',document.getElementById("infibox").checked); +} function exportData() { diff --git a/public/styles.css b/public/styles.css index f804433..c5a275c 100644 --- a/public/styles.css +++ b/public/styles.css @@ -794,16 +794,22 @@ transform:translateY(0%); .displayimg:first-of-type {margin-top:50px;} span#closegal { - background: var(--greyc); + background: var(--greyc); color: var(--textc); padding: 5px 10px; position: fixed; top: 5px; - right: 5px; + right: 0; border-radius: 10px; opacity: 0.95; - font-size:14px; - cursor:pointer; + font-size: 14px; + cursor: pointer; + left: 0; + width: 50px; + text-align: center; + opacity: 0.6; + margin: 0 auto; + backdrop-filter: blur(47px); } @media all and (display-mode: standalone) { header#header { diff --git a/public/subreddit.html b/public/subreddit.html index ddcb7a3..14a2dc7 100644 --- a/public/subreddit.html +++ b/public/subreddit.html @@ -86,34 +86,8 @@ url = url+'&before='+getget('before'); } -var req = new XMLHttpRequest(); -req.responseType = 'json'; -req.open('GET', url, true); -req.onload = function() { -var jsonResponse = req.response; - - -var titlesx = url.replace("https://www.reddit.com/r/", ""); -titlesx = titlesx.replace("/.json", ""); -document.title = titlesx; -posts = jsonResponse['data']['children']; - +makereq(url); -for(var item in posts) { -console.log("xx" + item); -pid = posts[item]['data']; -fill += postbuilder(pid); -} -fill += ''; -document.getElementById('body').innerHTML = fill; - runhsl(); -}; -req.send(null); } diff --git a/public/user.html b/public/user.html index 538d5c9..98a08ba 100644 --- a/public/user.html +++ b/public/user.html @@ -87,34 +87,7 @@ url = url+'&before='+getget('before'); } -var req = new XMLHttpRequest(); -req.responseType = 'json'; -req.open('GET', url, true); -req.onload = function() { -var jsonResponse = req.response; - - -var titlesx = url.replace("https://www.reddit.com/r/", ""); -titlesx = titlesx.replace("/.json", ""); -document.title = titlesx; -posts = jsonResponse['data']['children']; - - -for(var item in posts) { -console.log("xx" + item); -pid = posts[item]['data']; -fill += postbuilder(pid); -} -fill += ''; -document.getElementById('body').innerHTML = fill; - runhsl(); -}; -req.send(null); +makereq(url); } diff --git a/run.php b/run.php index 47b9692..a4c6cb8 100644 --- a/run.php +++ b/run.php @@ -28,7 +28,7 @@