feat: add alternative news feed sources

This commit is contained in:
SethBurkart123
2025-02-24 18:41:03 +11:00
parent 24ef85c39e
commit 696043e01a
7 changed files with 147 additions and 34 deletions
+3 -23
View File
@@ -1,5 +1,6 @@
import browser from 'webextension-polyfill'
import type { SettingsState } from "@/types/storage";
import { fetchNews } from './background/news';
function reloadSeqtaPages() {
const result = browser.tabs.query({})
@@ -48,18 +49,8 @@ browser.runtime.onMessage.addListener((request: any, _: any, sendResponse: (resp
break;
case 'sendNews':
const date = new Date();
const from =
date.getFullYear() +
'-' +
(date.getMonth() + 1) +
'-' +
(date.getDate() - 5);
const url = `https://newsapi.org/v2/everything?domains=abc.net.au&from=${from}&apiKey=17c0da766ba347c89d094449504e3080`;
GetNews(sendResponse, url);
fetchNews(request.source ?? 'australia', sendResponse);
return true;
default:
@@ -67,18 +58,6 @@ browser.runtime.onMessage.addListener((request: any, _: any, sendResponse: (resp
}
});
function GetNews(sendResponse: any, url: string) {
fetch(url)
.then((result) => result.json())
.then((response) => {
if (response.code == 'rateLimited') {
GetNews(sendResponse, url += '%00');
} else {
sendResponse({ news: response });
}
});
}
const DefaultValues: SettingsState = {
onoff: true,
animatedbk: true,
@@ -166,6 +145,7 @@ const DefaultValues: SettingsState = {
],
customshortcuts: [],
lettergrade: false,
newsSource: 'australia',
};
function SetStorageValue(object: any) {