// Income Tax Portal News Scraper async function fetchTaxUpdates() { try { const proxyUrl = 'https://cors-anywhere.herokuapp.com/'; // Using CORS proxy const targetUrl = 'https://www.incometax.gov.in/iec/foportal/latest-news'; const response = await fetch(proxyUrl + targetUrl); const html = await response.text(); const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); const newsItems = Array.from(doc.querySelectorAll('.latest-news li')); const taxNews = newsItems.map(item => { const title = item.textContent.trim(); const url = item.querySelector('a')?.href || '#'; return { title, url }; }); if (taxNews.length > 0) { const taxCard = document.querySelector('custom-notification-card[title="Income Tax Updates"]'); if (taxCard) { const newCount = taxNews.length; taxCard.setAttribute('new-content', `${newCount} new updates`); taxCard.setAttribute('last-checked', 'Just now'); // Update news section with tax updates const newsContainer = document.querySelector('.grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-3.gap-6'); if (newsContainer) { newsContainer.innerHTML = ''; taxNews.slice(0, 3).forEach((item, index) => { const newsCard = document.createElement('news-card'); newsCard.setAttribute('title', item.title); newsCard.setAttribute('source', 'Income Tax Dept.'); newsCard.setAttribute('date', 'Latest'); newsCard.setAttribute('summary', 'Official update from Income Tax portal'); newsCard.setAttribute('image', `http://static.photos/finance/640x360/${index+1}`); newsCard.setAttribute('url', item.url.startsWith('http') ? item.url : `https://www.incometax.gov.in${item.url}`); newsContainer.appendChild(newsCard); }); } } } } catch (error) { console.error('Error fetching tax updates:', error); } } document.addEventListener('DOMContentLoaded', function() { fetchTaxUpdates(); // Check for updates periodically setInterval(() => { fetchTaxUpdates(); }, 300000); // Check every 5 minutes // Request notification permission with better UX if (Notification.permission === "default") { setTimeout(() => { const shouldRequest = confirm('Would you like to receive notifications for new content?'); if (shouldRequest) { Notification.requestPermission().then(permission => { if (permission === "granted") { console.log('Notification permission granted'); } }); } }, 2000); } }); function showNotification(title, message) { if (Notification.permission === "granted") { new Notification(title, { body: message }); } }