Skip to content

Instantly share code, notes, and snippets.

@miratcan
Last active April 4, 2026 12:16
Show Gist options
  • Select an option

  • Save miratcan/f8e85a6bfc46888535074f104da6d3e8 to your computer and use it in GitHub Desktop.

Select an option

Save miratcan/f8e85a6bfc46888535074f104da6d3e8 to your computer and use it in GitHub Desktop.
kaydet.link - Browser console snippet: OG tag toplama + LLM (Gemini Nano) ile otomatik etiketleme smoke test
// kaydet.link - Sayfa Analiz Snippet v5
// OG tags toplar, kaydet.link backend uzerinden Gemini ile tag + aciklama uretir
// KULLANIM: Herhangi bir sayfada console'a yapistir
// NOT: kaydet.link'e giris yapmis olmalisin (session cookie gerekli)
(async () => {
// 1. OG tag'leri topla
const og = {};
document.querySelectorAll('meta[property^="og:"]').forEach(el => {
og[el.getAttribute('property')] = el.getAttribute('content');
});
if (!og['og:title']) og['og:title'] = document.title;
if (!og['og:description']) {
const desc = document.querySelector('meta[name="description"]');
if (desc) og['og:description'] = desc.getAttribute('content');
}
if (!og['og:url']) og['og:url'] = window.location.href;
// meta keywords
const kwMeta = document.querySelector('meta[name="keywords"]');
const keywords = kwMeta ? kwMeta.content : '';
// Sayfa icerigi
const content = document.body.innerText.slice(0, 2000);
console.log('%c=== OG TAGS ===', 'font-weight:bold; font-size:14px; color:#343dff');
console.table(og);
console.log('%cGemini analiz ediliyor...', 'color:#999');
// 2. kaydet.link backend'ine sor
try {
const response = await fetch('https://kaydet.link/api/analyze/', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.cookie.match(/csrftoken=([^;]+)/)?.[1] || '',
},
body: JSON.stringify({
title: og['og:title'] || '',
url: og['og:url'],
description: og['og:description'] || '',
keywords: keywords,
content: content,
}),
});
if (!response.ok) {
const err = await response.json();
console.error('Hata:', err.error || response.statusText);
return;
}
const result = await response.json();
console.log('');
console.log('%c=== GEMINI SONUCLARI ===', 'font-weight:bold; font-size:14px; color:#090');
console.log('%cEtiketler: ' + result.tags.join(', '), 'font-weight:bold; color:#090; font-size:13px');
console.log('');
console.log('%cAciklama:', 'font-weight:bold');
console.log(result.description);
console.log('');
console.log('%c=== KAYDET.LINK KAYIT OZETI ===', 'font-weight:bold; font-size:14px; color:#343dff');
console.log(`Baslik: ${og['og:title'] || '-'}`);
console.log(`URL: ${og['og:url']}`);
console.log(`Gorsel: ${og['og:image'] || 'yok'}`);
console.log(`Etiketler: ${result.tags.join(', ')}`);
console.log(`Aciklama: ${result.description.slice(0, 200)}...`);
} catch (err) {
console.error('Istek hatasi:', err);
console.log('kaydet.link\'e giris yapmis oldugundan emin ol.');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment