From c9c52e95560465b09c36c25751adc86558a45be7 Mon Sep 17 00:00:00 2001 From: avadhesh18 Date: Fri, 31 May 2024 02:35:41 +0530 Subject: [PATCH] trying with fetch --- public/functions.js | 43 ++++++++++++++++++++++++++++++++++++++++++- run.php | 4 ++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/public/functions.js b/public/functions.js index 287c8fc..710ea6a 100644 --- a/public/functions.js +++ b/public/functions.js @@ -74,7 +74,7 @@ document.getElementById("subssearchi").focus(); // return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue; //} -function makereq(url){ +function xmakereq(url){ var fill = ''; var req = new XMLHttpRequest(); req.responseType = 'json'; @@ -110,6 +110,47 @@ document.getElementById('body').innerHTML = '
Can\' }; req.send(null); } +async function makereq(url) { + try { + let response = await fetch(url, { redirect: 'follow' }); + if (!response.ok) { + throw new Error('Network response was not ok ' + response.statusText); + } + + let jsonResponse = await response.json(); + let fill = ''; + let titlesx = url.replace("https://www.reddit.com/r/", ""); + titlesx = titlesx.replace("/.json", ""); + document.title = titlesx; + + let posts = jsonResponse['data']['children']; + for (let item of posts) { + console.log("xx" + item); + let pid = item['data']; + fill += postbuilder(pid); + } + + fill += ''; + document.getElementById('body').innerHTML = fill; + + runhsl(); + if (curinfi == "true") { + observe(); + } + } catch (error) { + document.getElementById('body').innerHTML = `
Can't load content!
I know about the error of home feed and user feed not working(individual subreddits are working). Reddit is making it hard to fix but I am trying. Meanwhile I have made an iOS App(free,ad-free, fast) to get around this and will launch it in 2-3 days. You can subscribe using your email below and I will send you an email when the app is ready.There can be multiple reasons for this, your browser's aggressive privacy settings may be blocking the one call to reddit.com RDX makes. This happens usually when you use a VPN/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.
`; + } +} function scorllmore() { const url = nexturl; diff --git a/run.php b/run.php index 7710bbd..0a410b5 100644 --- a/run.php +++ b/run.php @@ -46,7 +46,7 @@ $data = str_replace('',$headhtml,$data); -$data = str_replace('','