Skip to content

Commit

Permalink
trying with fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
avadhesh18 committed May 30, 2024
1 parent 0a8a118 commit c9c52e9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
43 changes: 42 additions & 1 deletion public/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -110,6 +110,47 @@ document.getElementById('body').innerHTML = '<center style="padding:15px;">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 += '<div class="navigate">';
let curpage = window.location.href.replace(/\&after.*/, '');
if (jsonResponse['data']['after'] != null) {
if (curpage.indexOf("?") === -1) {
curpage = curpage + '?a=b';
}
fill += '<a class="next" href="' + curpage + '&after=' + jsonResponse['data']['after'] + '">Next page</a><div id="sxpy"></div><div id="sentinel"> </div>';
let nextseturl = curpage + '&after=' + jsonResponse['data']['after'];
let nexturl = url.split('&after')[0] + "&after=" + jsonResponse['data']['after'];
}
fill += '</div>';
document.getElementById('body').innerHTML = fill;

runhsl();
if (curinfi == "true") {
observe();
}
} catch (error) {
document.getElementById('body').innerHTML = `<center style="padding:15px;">Can't load content!<br><b>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.</b><iframe width="340" height="305" src="https://7a945f05.sibforms.com/serve/MUIFALUnKUyQYm475r-rbc10FSp870Ra3M3xoAR8XhhH5n1peSVzsoaHNqfh1r8UUqRbVjg_fljGuixCyVnGnCo3dQDsIrAat_5vYvjlI25DzLl6VEwr2SCM9GzniHmLjV7VpsHzaO0F26IGQPRIThB4OimW0sdaN9Eq8cTYV79Abo2j1HHLb-77KQkDzWtHHMdmSKbUXcOEd9Pa" frameborder="0" scrolling="auto" allowfullscreen style="display: block;margin-left: auto;margin-right: auto;max-width: 100%;"></iframe><small>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.<br> 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.</small></center>`;
}
}

function scorllmore() {
const url = nexturl;
Expand Down
4 changes: 2 additions & 2 deletions run.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
$data = str_replace('<!--headhtml-->',$headhtml,$data);


$data = str_replace('</body>','<div class="footer"> <a rel="nofollow" href="https://www.buymeacoffee.com/overdevsapps" class="bmac"><img src="bmac.png" width="150" alt="donate"></a><br>If you use rdx for Reddit&reg; please provide <a href="contact.html">Feedback</a> and <a href="https://www.buymeacoffee.com/overdevsapps" rel="nofollow">Donate</a>.<br><br><small><a href="new.html"> What\'s new?</a> | <a href="settings.html">Settings</a> | <a href="https://github.com/avadhesh18/rdx/">Star on Github</a> | <a href="https://apps.apple.com/us/app/miai-create-your-ai-friend/id6475200501">Try My AI Chat app </a></small></div> <div id="popitup" style="display:none;">
$data = str_replace('</body>','<div class="footer"> <a rel="nofollow" href="https://www.buymeacoffee.com/overdevsapps" class="bmac"><img src="bmac.png" width="150" alt="donate"></a><br>If you use rdx for Reddit&reg; please provide <a href="contact.html">Feedback</a> and <a href="https://www.buymeacoffee.com/overdevsapps" rel="nofollow">Donate</a>.<br><br><small><a href="new.html"> What\'s new?</a> | <a href="settings.html">Settings</a> | <a href="https://github.com/avadhesh18/rdx/">Star on Github</a> | <a href="https://apps.apple.com/us/app/miai-create-your-ai-friend/id6475200501">Try My AI Chat app </a></small></div> <div id="popitup" style="display:none;">
<span onclick="document.getElementById(\'popitup\').style.display=\'none\'">Cancel</span>
<div id="helptext"></div><textarea class="cmntarea" id="commentText" placeholder="Write a reply!" required></textarea>
<input id="cmtid" value="" type="hidden"/> <input id="actype" value="" type="hidden"/> <button id="cmntbtn" onclick="apiAction();">Submit</button>
</div> <!-- rdx --></body>',$data);
if($file == 'html/index.html')
{
$data = str_replace('<!-- rdx -->','<div class="infotext">
<h1>Explore RDX for Reddit : A Fast and Lightweight Web Viewer Inspired by Apollo</h1>
<h1>Explore RDX for Reddit: A Fast and Lightweight Web Viewer Inspired by Apollo</h1>
<p>Discover a seamless Reddit browsing experience with rdx, a mobile-friendly web viewer designed for speed and simplicity. Based on the now closed Apollo app, rdx allows you to navigate Reddit without the distraction of ads.</p>
<h2>Enjoy Reddit Anywhere: rdx\'s Mobile-Friendly Design and Dark Mode</h2>
<p>Experience the freedom of browsing Reddit on the mobile easily with rdx\'s mobile-friendly design. The interface is optimized for various devices, ensuring a smooth experience across different screen sizes. Additionally, rdx offers a Dark Mode for users who prefer a more comfortable and eye-friendly viewing experience, making it easy to enjoy Reddit in any lighting condition.</p>
Expand Down

0 comments on commit c9c52e9

Please sign in to comment.