Tangled notifications browser extension
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 17 lines 684 B view raw
1const BASE_URL = "https://tangled.org"; 2 3export const getNotificationsUrl = (): string => `${BASE_URL}/notifications`; 4 5export const getNotificationsUrlPattern = (): string => 6 `${BASE_URL}/notifications*`; 7 8export const fetchNotificationCount = async (): Promise<number> => { 9 const response = await fetch(`${BASE_URL}/notifications/count`, { 10 credentials: "include", 11 }); 12 // FIX: requires backend to return 401 when not logged in (currently returns 200 even if not logged in) 13 if (!response.ok) throw new Error(`HTTP ${response.status}`); 14 const html = await response.text(); 15 const match = html.match(/>\s*(\d+\+?)\s*</); 16 return match ? parseInt(match[1], 10) : 0; 17};