diff --git a/background.js b/background.js index 16cf762..182bf6a 100644 --- a/background.js +++ b/background.js @@ -17,7 +17,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { // ─── Core API call ─────────────────────────────────────────────────────────── -async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText', jobDescription = '' }) { +async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText', jobDescription = '', jobTitle = '' }) { // Rate limit check const canProceed = await checkRateLimit(); if (!canProceed) { @@ -45,7 +45,8 @@ async function handleGeminiRequest({ apiKey, prompt, tab, action = 'generateText action: action, apiKey: apiKey, prompt: trimmedPrompt, - jobDescription: jobDescription + jobDescription: jobDescription, + jobTitle: jobTitle }) }); diff --git a/content.js b/content.js index 74f14cd..771ef44 100644 --- a/content.js +++ b/content.js @@ -501,6 +501,7 @@ payload: { apiKey: settings.apiKey, jobDescription: jobData.description, + jobTitle: jobData.jobTitle || 'Job', action: 'generatePdf' } }, resolve); diff --git a/server/generate_cv.php b/server/generate_cv.php index 7362d96..b3e4ad2 100644 --- a/server/generate_cv.php +++ b/server/generate_cv.php @@ -112,10 +112,15 @@ Job Description: $dompdf->render(); $pdfOutput = $dompdf->output(); + $rawJobTitle = $data['jobTitle'] ?? 'Job'; + $safeJobTitle = preg_replace('/[^a-zA-Z0-9\-_]/', '_', $rawJobTitle); + $safeJobTitle = trim($safeJobTitle, '_'); + $fileName = "Hamza_Ayed - {$safeJobTitle}.pdf"; + echo json_encode([ "success" => true, "pdf" => base64_encode($pdfOutput), - "filename" => "Tailored_CV.pdf" + "filename" => $fileName ]); } catch (Exception $e) { http_response_code(500); @@ -132,7 +137,7 @@ if ($action === 'generateText') { $payload = json_encode([ "contents" => [["parts" => [["text" => $prompt]]]], - "generationConfig" => ["temperature" => 0.7, "maxOutputTokens" => 2048] + "generationConfig" => ["temperature" => 0.7, "maxOutputTokens" => 8192] ]); $ch = curl_init($geminiUrl);