Skip to content

Commit

Permalink
Update redditSaver.js
Browse files Browse the repository at this point in the history
Fix for reddit block problem
  • Loading branch information
erohtar committed Jun 12, 2023
1 parent cea8d2a commit 990db67
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions redditSaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ fs.rmSync(path.join(wDir, 'saved.json'), {
//download latest json AND create notes once download finishes
// https://stackoverflow.com/a/62588602
function get(url, resolve, reject) {
https.get(url, (res) => {
// if any other status codes are returned, those needed to be added here
//set browser agent to chrome
const options = {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
};

https.get(url, options, (res) => {
// if any other status codes are returned, those needed to be added here
if(res.statusCode === 301 || res.statusCode === 302) {
return get(res.headers.location, resolve, reject)
}
Expand Down

0 comments on commit 990db67

Please sign in to comment.