Add AI Summary To Your Website
A code guide to make buttons that send website text to AI for a quick summary.
Prompt
I want to add an 'AI Summary' feature to my website. Write the code in a single HTML file (HTML/JS/CSS) to achieve the following:
Text Extraction: Create a JavaScript function that extracts the most important text from the current page (e.g., from the <main> tag or all <p> elements), removes excess whitespace, and truncates the text to a safe number of characters (e.g., 2500).
Prompt Construction: Create a variable for a prompt that combines the page URL and the extracted text. The prompt should instruct the AI to provide a short, powerful summary of the specific page.
AI Tool Integration: Create a row of interactive icons (or buttons) for popular AI tools such as ChatGPT, Claude, Grok, Gemini, and Perplexity.
Dynamic Links: Ensure that when a user clicks an icon, a new tab opens to that specific AI tool. The constructed prompt is included directly in the URL (URL-encoded), so the user only needs to press 'enter' in the AI tool.
Styling: Provide a modern, minimalist design that fits within a footer, with hover effects for the icons.