Skip to content

Commit caae603

Browse files
committed
feat: adds tldr support
1 parent 93acfab commit caae603

3 files changed

Lines changed: 460 additions & 2 deletions

File tree

index.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,61 @@ <h5 class="u-mt-none u-text-light">
678678
</include-footer>
679679
<!-- end of footer section -->
680680

681+
<!-- TLDR Generator Button -->
682+
<button
683+
id="tldr-generator-btn"
684+
class="c-tldr-btn"
685+
aria-label="Generate TLDR"
686+
>
687+
Generate TL;DR
688+
</button>
689+
690+
<!-- TLDR Modal -->
691+
<div
692+
id="tldr-modal"
693+
class="c-tldr-modal"
694+
role="dialog"
695+
aria-labelledby="tldr-modal-title"
696+
aria-hidden="true"
697+
>
698+
<div class="c-tldr-modal__overlay"></div>
699+
<div class="c-tldr-modal__content">
700+
<h2 id="tldr-modal-title" class="c-tldr-modal__title">
701+
Generate TL;DR
702+
</h2>
703+
<p class="c-tldr-modal__subtitle">Choose a style for your summary</p>
704+
<div class="c-tldr-modal__categories">
705+
<button
706+
class="c-tldr-category u-link-clean"
707+
data-category="professional"
708+
>
709+
<span class="c-tldr-category__title">Professional</span>
710+
<span class="c-tldr-category__desc"
711+
>LinkedIn bios, job applications, networking events</span
712+
>
713+
</button>
714+
<button class="c-tldr-category u-link-clean" data-category="friendly">
715+
<span class="c-tldr-category__title">Friendly</span>
716+
<span class="c-tldr-category__desc"
717+
>Social media bios, friend introductions, casual meetups</span
718+
>
719+
</button>
720+
<button class="c-tldr-category u-link-clean" data-category="dating">
721+
<span class="c-tldr-category__title">Dating</span>
722+
<span class="c-tldr-category__desc"
723+
>Dating app bios, personal connections</span
724+
>
725+
</button>
726+
</div>
727+
<button
728+
class="c-tldr-modal__close u-link-clean"
729+
aria-label="Close modal"
730+
>
731+
close
732+
</button>
733+
</div>
734+
</div>
735+
681736
<!-- linking script sections -->
682737
<script type="text/javascript" src="./script.js" defer></script>
683738
</body>

script.js

Lines changed: 255 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,266 @@ const scrollManager = () => {
162162
});
163163
};
164164

165+
/**
166+
* TLDR Generator functionality
167+
*/
168+
const tldrGenerator = (() => {
169+
let modal, openBtn, closeBtn, categoryButtons;
170+
171+
// Prompt templates for each category - optimized for real-world use cases
172+
const prompts = {
173+
professional: `Visit ${window.location.origin} and analyze the website content. Also check https://github.com/ragarwalll if mentioned.
174+
175+
Create a professional TLDR summary that would be useful for:
176+
- Recruiters scanning LinkedIn profiles
177+
- Hiring managers reviewing candidates
178+
- Potential collaborators or clients
179+
- Networking events and introductions
180+
181+
REQUIREMENTS:
182+
1. Extract key information:
183+
- Current role and company
184+
- Years of experience and career progression
185+
- Core technical skills (be specific: languages, frameworks, tools)
186+
- Notable projects with impact/metrics (downloads, users, etc.)
187+
- Problem-solving approach and work philosophy
188+
- Educational background
189+
190+
2. Format as a concise professional bio (2-3 short paragraphs):
191+
- First paragraph: Current role, experience level, and primary expertise
192+
- Second paragraph: Key achievements, projects, and technical strengths
193+
- Third paragraph (optional): Approach to work, values, or unique differentiators
194+
195+
3. Style guidelines:
196+
- Professional but approachable tone
197+
- Use specific technologies and metrics when available
198+
- Focus on outcomes and impact, not just responsibilities
199+
- Avoid buzzwords and generic statements
200+
- Be authentic to the website's tone
201+
- No emojis
202+
203+
4. Make it scannable and LinkedIn-ready - something that can be copied directly into a professional profile or email introduction.`,
204+
205+
friendly: `Visit ${window.location.origin} and read through the website to understand Rahul's personality and interests.
206+
207+
Create a friendly, casual TLDR that would be useful for:
208+
- Introducing him to new friends or social groups
209+
- Social media bios (Twitter, Instagram, etc.)
210+
- Casual networking or meetups
211+
- When someone asks "tell me about yourself" in a non-professional setting
212+
213+
REQUIREMENTS:
214+
1. Extract key information:
215+
- Personal background and story
216+
- Hobbies, interests, and passions
217+
- Personality traits and quirks
218+
- Creative pursuits and adventures
219+
- What makes him interesting as a person
220+
- Projects mentioned casually (not too technical)
221+
222+
2. Format as a friendly introduction (2-3 paragraphs):
223+
- First paragraph: Who he is and what he's passionate about
224+
- Second paragraph: Interests, hobbies, and personality highlights
225+
- Third paragraph: Fun facts or what makes him unique
226+
227+
3. Style guidelines:
228+
- Warm, conversational, and approachable
229+
- Light humor is welcome
230+
- Focus on personality over professional achievements
231+
- Use casual language but stay authentic
232+
- Can include emojis sparingly if it fits the tone
233+
- Make it relatable and human
234+
235+
4. Make it something a friend would say when introducing him - natural, engaging, and easy to remember.`,
236+
237+
dating: `Visit ${window.location.origin} and analyze the website to understand Rahul's personality, interests, and what makes him interesting.
238+
239+
Create an engaging dating profile TLDR that would be useful for:
240+
- Dating apps (Hinge, Bumble, Tinder bios)
241+
- Social introductions in dating contexts
242+
- Personal connection and attraction
243+
244+
REQUIREMENTS:
245+
1. Extract key information:
246+
- Age and location (if mentioned)
247+
- Unique hobbies and interests
248+
- Personality traits and energy
249+
- Creative pursuits and adventures
250+
- What makes him stand out
251+
- Balance of professional and personal life
252+
- Values and what matters to him
253+
254+
2. Format as an attractive dating profile (2-3 short paragraphs):
255+
- First paragraph: Engaging hook that shows personality and confidence
256+
- Second paragraph: Interests, passions, and what he enjoys doing
257+
- Third paragraph: What makes him interesting or what he's looking for (if appropriate)
258+
259+
3. Style guidelines:
260+
- Confident but not arrogant
261+
- Authentic and genuine
262+
- Playful and charming
263+
- Show personality, not just list facts
264+
- Avoid clichés ("I love travel and food")
265+
- Be specific about interests
266+
- Light humor and wit are welcome
267+
- Emotionally intelligent tone
268+
269+
4. Make it appealing and authentic - something that would make someone want to know more about him. Focus on what makes him interesting as a person, not just his job.`,
270+
};
271+
272+
const openModal = () => {
273+
console.log("Opening modal", modal);
274+
if (modal) {
275+
modal.setAttribute("aria-hidden", "false");
276+
document.body.style.overflow = "hidden";
277+
} else {
278+
console.error("Modal not found when trying to open");
279+
}
280+
};
281+
282+
const closeModal = () => {
283+
if (modal) {
284+
modal.setAttribute("aria-hidden", "true");
285+
document.body.style.overflow = "";
286+
}
287+
};
288+
289+
// Helper function to show notification
290+
const showNotification = (message, subMessage) => {
291+
// Add animation style if not already added
292+
if (!document.getElementById("tldr-notification-style")) {
293+
const style = document.createElement("style");
294+
style.id = "tldr-notification-style";
295+
style.textContent = `
296+
@keyframes slideDown {
297+
from {
298+
opacity: 0;
299+
transform: translateX(-50%) translateY(-20px);
300+
}
301+
to {
302+
opacity: 1;
303+
transform: translateX(-50%) translateY(0);
304+
}
305+
}
306+
`;
307+
document.head.appendChild(style);
308+
}
309+
310+
const notification = document.createElement("div");
311+
notification.className = "c-tldr-notification";
312+
notification.innerHTML = `
313+
<div style="font-weight: 600; margin-bottom: 4px;">${message}</div>
314+
${
315+
subMessage
316+
? `<div style="font-size: 0.85rem; opacity: 0.9;">${subMessage}</div>`
317+
: ""
318+
}
319+
`;
320+
notification.style.cssText = `
321+
position: fixed;
322+
top: 20px;
323+
left: 50%;
324+
transform: translateX(-50%);
325+
background: var(--color-text);
326+
color: var(--color-bg);
327+
padding: 16px 24px;
328+
border-radius: 8px;
329+
box-shadow: 0 4px 16px rgba(0,0,0,0.3);
330+
z-index: 3000;
331+
font-size: 0.9rem;
332+
max-width: 90%;
333+
text-align: center;
334+
animation: slideDown 0.3s ease-out;
335+
`;
336+
337+
document.body.appendChild(notification);
338+
339+
// Remove notification after 5 seconds
340+
setTimeout(() => {
341+
notification.style.animation = "slideDown 0.3s ease-out reverse";
342+
setTimeout(() => notification.remove(), 300);
343+
}, 5000);
344+
};
345+
346+
const generateTLDR = (category) => {
347+
const prompt = prompts[category];
348+
if (!prompt) {
349+
console.error("Invalid category:", category);
350+
return;
351+
}
352+
353+
// Try URL parameter method first
354+
const encodedPrompt = encodeURIComponent(prompt);
355+
const chatgptUrl = `https://chat.openai.com/?q=${encodedPrompt}`;
356+
357+
// Open ChatGPT with URL parameter
358+
window.open(chatgptUrl, "_blank");
359+
360+
closeModal();
361+
};
362+
363+
const init = () => {
364+
// Query DOM elements when initializing
365+
modal = document.getElementById("tldr-modal");
366+
openBtn = document.getElementById("tldr-generator-btn");
367+
closeBtn = modal?.querySelector(".c-tldr-modal__close");
368+
categoryButtons = modal?.querySelectorAll(".c-tldr-category");
369+
370+
if (!modal || !openBtn) {
371+
console.error("TLDR Generator: Modal or button not found", {
372+
modal,
373+
openBtn,
374+
});
375+
return;
376+
}
377+
378+
console.log("TLDR Generator initialized", {
379+
modal,
380+
openBtn,
381+
categoryButtons: categoryButtons?.length,
382+
});
383+
384+
// Open modal
385+
openBtn.addEventListener("click", (e) => {
386+
console.log("TLDR button clicked");
387+
openModal();
388+
});
389+
390+
// Close modal
391+
closeBtn?.addEventListener("click", closeModal);
392+
393+
// Close on overlay click
394+
const overlay = modal.querySelector(".c-tldr-modal__overlay");
395+
overlay?.addEventListener("click", closeModal);
396+
397+
// Close on Escape key
398+
document.addEventListener("keydown", (e) => {
399+
if (e.key === "Escape" && modal.getAttribute("aria-hidden") === "false") {
400+
closeModal();
401+
}
402+
});
403+
404+
// Handle category selection
405+
categoryButtons?.forEach((btn) => {
406+
btn.addEventListener("click", () => {
407+
const category = btn.getAttribute("data-category");
408+
generateTLDR(category);
409+
});
410+
});
411+
};
412+
413+
return { init };
414+
})();
415+
165416
// Initialize once DOM is loaded
166417
if (document.readyState === "loading") {
167-
document.addEventListener("DOMContentLoaded", ()=>{
418+
document.addEventListener("DOMContentLoaded", () => {
168419
faviconHandler();
169420
scrollManager();
421+
tldrGenerator.init();
170422
});
171423
} else {
172424
scrollManager();
173425
document.addEventListener("visibilitychange", faviconHandler);
174-
}
426+
tldrGenerator.init();
427+
}

0 commit comments

Comments
 (0)