Health News
Top Stories
// server.mjs import { createServer } from 'node:http'; const server = createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World!\n'); }); // starts a simple http server locally on port 3000 server.listen(3000, '127.0.0.1', () => { console.log('Listening on 127.0.0.1:3000'); }); // run with `node server.mjs` const axios = require('axios'); const { JSDOM } = require('jsdom'); async function fetchGoogleDoc(url) { try { const response = await axios.get(url); return response.data; } catch (error) { console.error('Error fetching the Google Doc:', error); throw error; } } function parseContent(html) { const dom = new JSDOM(html); const document = dom.window.document; const rows = Array.from(document.querySelectorAll('table tr')); const characters = []; let maxX = 0, maxY = 0; rows.slice(1).forEach(row => { const cells = row.querySelectorAll('td'); if (cells.length === 3) { const x = parseInt(cells[0].textContent.trim(), 10); const char = cells[1].textContent.trim(); const y = parseInt(cells[2].textContent.trim(), 10); characters.push({ char, x, y }); if (x > maxX) maxX = x; if (y > maxY) maxY = y; } }); return { characters, maxX, maxY }; } function createGrid(maxX, maxY) { return Array.from({ length: maxY + 1 }, () => Array(maxX + 1).fill(' ')); } function populateGrid(grid, characters) { characters.forEach(({ char, x, y }) => { grid[y][x] = char; }); } function printGrid(grid) { grid.forEach(row => { console.log(row.join('')); }); } async function decodeMessage(url) { const html = await fetchGoogleDoc(url); const { characters, maxX, maxY } = parseContent(html); const grid = createGrid(maxX, maxY); populateGrid(grid, characters); printGrid(grid); } // URL of the Google Doc const url = 'https://docs.google.com/document/d/e/2PACX-1vShuWova56o7XS1S3LwEIzkYJA8pBQENja01DNnVDorDVXbWakDT4NioAScvP1OCX6eeKSqRyzUW_qJ/pub'; decodeMessage(url);