Auto-deploy: 2026-05-17 01:38:08

This commit is contained in:
Hamza-Ayed
2026-05-17 01:38:08 +03:00
parent a433b2f7ae
commit d547decc60
3 changed files with 194 additions and 115 deletions

View File

@@ -339,9 +339,10 @@
</div>
<!-- Actions -->
<div id="lja-actions">
<button id="lja-analyze-btn">⚡ Analyze This Job</button>
<button id="lja-copy-btn" style="display:none">📋 Copy</button>
<div id="lja-actions" style="display: flex; gap: 8px;">
<button id="lja-pdf-btn" style="background: #1a237e; border: 1px solid #3949ab; color: white; padding: 10px; border-radius: 6px; font-weight: 600; cursor: pointer; flex: 1; transition: 0.2s;">📥 Get ATS PDF</button>
<button id="lja-analyze-btn" style="flex: 1.5;">⚡ Analyze Job</button>
<button id="lja-copy-btn" style="display:none; flex: 0.5;">📋 Copy</button>
</div>
<!-- Loading -->
@@ -474,6 +475,68 @@
await runAnalysis(settings, jobData, currentTab, results, root, loading, loadingText, copyBtn);
});
// ── Generate PDF Action
const pdfBtn = root.querySelector('#lja-pdf-btn');
if (pdfBtn) {
pdfBtn.addEventListener('click', async () => {
if (!jobData.description && !jobData.jobTitle) {
showPanelToast(root, '⚠️ No job detected.');
return;
}
const settings = await getSettings();
if (!settings.apiKey) {
showPanelToast(root, '⚠️ Set your API key first!');
return;
}
try {
pdfBtn.textContent = '⏳ Generating...';
pdfBtn.disabled = true;
showPanelToast(root, 'Generating ATS CV PDF via Server...', 'info');
const response = await new Promise(resolve => {
chrome.runtime.sendMessage({
type: 'GEMINI_REQUEST',
payload: {
apiKey: settings.apiKey,
jobDescription: jobData.description,
action: 'generatePdf'
}
}, resolve);
});
if (response && response.success && response.data && response.data.pdf) {
// Convert base64 to Blob and trigger download
const binaryString = window.atob(response.data.pdf);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const blob = new Blob([bytes], { type: 'application/pdf' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = response.data.filename || 'Hamza_Ayed_CV.pdf';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
showPanelToast(root, '✅ PDF Downloaded Successfully!', 'success');
} else {
throw new Error(response?.error || 'Failed to generate PDF from server');
}
} catch (e) {
showPanelToast(root, '❌ PDF Error: ' + e.message, 'error');
} finally {
pdfBtn.textContent = '📥 Get ATS PDF';
pdfBtn.disabled = false;
}
});
}
// ── Copy button
copyBtn.addEventListener('click', () => {
if (results[currentTab]) {