mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
fix: idk something to do with news ratelimiting :)
This commit is contained in:
@@ -2726,6 +2726,7 @@ function SendNewsPage() {
|
|||||||
AppendLoadingSymbol('newsloading', '#news-container')
|
AppendLoadingSymbol('newsloading', '#news-container')
|
||||||
|
|
||||||
browser.runtime.sendMessage({ type: 'sendNews' }).then(function (response) {
|
browser.runtime.sendMessage({ type: 'sendNews' }).then(function (response) {
|
||||||
|
console.log(response)
|
||||||
let newsarticles = response.news.articles
|
let newsarticles = response.news.articles
|
||||||
var newscontainer = document.querySelector('#news-container')
|
var newscontainer = document.querySelector('#news-container')
|
||||||
document.getElementById('newsloading')!.remove()
|
document.getElementById('newsloading')!.remove()
|
||||||
|
|||||||
+12
-13
@@ -116,16 +116,7 @@ browser.runtime.onMessage.addListener((request: any, _sender: any, sendResponse:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sendNews':
|
case 'sendNews':
|
||||||
GetNews(sendResponse);
|
console.log("Sending news")
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
console.log('Unknown request type');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function GetNews(sendResponse: any) {
|
|
||||||
// Gets the current date
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
|
||||||
const from =
|
const from =
|
||||||
@@ -135,14 +126,22 @@ function GetNews(sendResponse: any) {
|
|||||||
'-' +
|
'-' +
|
||||||
(date.getDate() - 1);
|
(date.getDate() - 1);
|
||||||
|
|
||||||
let url = `https://newsapi.org/v2/everything?domains=abc.net.au&from=${from}&apiKey=17c0da766ba347c89d094449504e3080`;
|
const url = `https://newsapi.org/v2/everything?domains=abc.net.au&from=${from}&apiKey=17c0da766ba347c89d094449504e3080`;
|
||||||
|
|
||||||
|
GetNews(sendResponse, url);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
console.log('Unknown request type');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function GetNews(sendResponse: any, url: string) {
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then((result) => result.json())
|
.then((result) => result.json())
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.code == 'rateLimited') {
|
if (response.code == 'rateLimited') {
|
||||||
url += '%00';
|
GetNews(sendResponse, url += '%00');
|
||||||
GetNews({});
|
|
||||||
} else {
|
} else {
|
||||||
sendResponse({ news: response });
|
sendResponse({ news: response });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user