قاعدة البيانات المحلية ID
بواسطة morbah |
832820196297510160,8587794867133706106,4606422210361223385
مدوناتي المفعلة
لعرض قائمة مدوناتك المفعلة، يرجى تسجيل الدخول بحسابك في جوجل.
مرحباً !
هذه قائمة بالمدونات المفعلة والمرتبطة بحسابك:
جاري جلب ومقارنة البيانات...
<!--==========================================================-->
<!--== MY ACTIVATED BLOGS (LOCAL VERSION) - FINAL CODE ==-->
<!--==========================================================-->
<!--1. قاعدة البيانات المحلية: ضع أرقام الـ ID هنا مفصولة بفاصلة-->
<div id="activated-ids-source" style="display: none;">
832820196297510160,8587794867133706106,4606422210361223385
</div>
<!--2. واجهة التطبيق-->
<div id="my-blogs-app">
<style>
#my-blogs-app { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; max-width: 700px; margin: 50px auto; padding: 25px; text-align: center; background: #fff; border-radius: 12px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); direction: rtl; }
.app-screen { display: none; }
.app-screen.show { display: block; animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
#my-blogs-app h2 { margin-top: 0; font-size: 26px; color: #1c1e21; }
#my-blogs-app p { color: #555; line-height: 1.7; font-size: 16px; }
#my-blogs-app button { cursor: pointer; border: none; border-radius: 8px; padding: 14px 25px; font-size: 16px; font-weight: bold; transition: all 0.2s ease; }
#login-btn { background-color: #4285F4; color: white; display: inline-flex; align-items: center; gap: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
#login-btn:hover { background-color: #357ae8; }
#login-btn:disabled { background-color: #ccc; cursor: not-allowed; }
#login-btn img { width: 22px; height: 22px; }
#activated-blogs-list { list-style: none; padding: 0; margin-top: 20px; text-align: right; }
#activated-blogs-list li { padding: 15px; background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 8px; margin-bottom: 10px; }
.blog-info { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.blog-name { font-weight: 600; font-size: 18px; color: #212529; }
.blog-id { font-family: monospace; background: #e9ecef; padding: 3px 8px; border-radius: 4px; color: #495057; font-size: 14px; direction: ltr; user-select: all; }
.message { margin-top: 20px; font-weight: bold; padding: 20px; border-radius: 8px; font-size: 16px; }
.message.loading { color: #007bff; background-color: #e7f3ff; }
.message.error { color: #721c24; background-color: #f8d7da; }
.message.info { color: #0c5460; background-color: #d1ecf1; }
</style>
<div class="app-screen show" id="login-screen">
<h2>مدوناتي المفعلة</h2>
<p>لعرض قائمة مدوناتك المفعلة، يرجى تسجيل الدخول بحسابك في جوجل.</p>
<button disabled="" id="login-btn"><img alt="Google icon" loading="lazy" src="https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg" /> جاري التحميل...</button>
</div>
<div class="app-screen" id="result-screen">
<h2>مرحباً <strong id="user-email-display"></strong>!</h2>
<p>هذه قائمة بالمدونات المفعلة والمرتبطة بحسابك:</p>
<div class="message loading" id="result-message">جاري جلب ومقارنة البيانات...</div>
<ul id="activated-blogs-list"></ul>
</div>
</div>
<!--3. تحميل مكتبات جوجل-->
<script async="" defer="" onload="gisLoaded()" src="https://accounts.google.com/gsi/client"></script>
<script async="" defer="" onload="gapiLoaded()" src="https://apis.google.com/js/api.js"></script>
<!--4. الكود الرئيسي للتطبيق-->
<script>
// ============= CONFIGURATION =============
const CLIENT_ID = '961928140508-vd8p21kn2vuit9conn6mlabe0lgok659.apps.googleusercontent.com';
const API_KEY = 'AIzaSyDIzfkhbpi9r8eiuT_1PZ9HlmVpywm69HY';
// =========================================
const DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/blogger/v3/rest"];
// قللنا الصلاحيات لأننا نحتاج للقراءة فقط
const SCOPES = 'https://www.googleapis.com/auth/blogger.readonly https://www.googleapis.com/auth/userinfo.email';
let tokenClient;
let gapiReady = false, gisReady = false;
// --- دوال التحميل والتحقق من الجاهزية ---
function gapiLoaded() {
gapi.load('client', () => {
gapi.client.init({ apiKey: API_KEY, discoveryDocs: DISCOVERY_DOCS })
.then(() => { gapiReady = true; checkIfReady(); });
});
}
function gisLoaded() {
tokenClient = google.accounts.oauth2.initTokenClient({
client_id: CLIENT_ID,
scope: SCOPES,
callback: handleTokenResponse,
});
gisReady = true;
checkIfReady();
}
function checkIfReady() {
if (gapiReady && gisReady) {
const loginBtn = document.getElementById('login-btn');
loginBtn.disabled = false;
loginBtn.innerHTML = '<img src="https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg" alt="Google icon"> تسجيل الدخول لعرض مدوناتك';
loginBtn.onclick = () => tokenClient.requestAccessToken({ prompt: 'consent' });
}
}
// --- الدالة الرئيسية بعد تسجيل الدخول ---
async function handleTokenResponse(tokenResponse) {
if (tokenResponse.error) {
showResult('error', 'فشل تسجيل الدخول. يرجى المحاولة مرة أخرى.');
return;
}
showScreen('result-screen');
try {
// 1. جلب معلومات المستخدم
const userInfo = await gapi.client.request({ path: 'https://www.googleapis.com/oauth2/v3/userinfo' });
document.getElementById('user-email-display').textContent = userInfo.result.email;
// 2. قراءة قائمة الـ IDs المفعلة من الصفحة نفسها
const activatedIdsSource = document.getElementById('activated-ids-source');
if (!activatedIdsSource) {
throw new Error("لم يتم العثور على مصدر قائمة التفعيلات في الصفحة.");
}
const activatedIds = activatedIdsSource.textContent.trim().split(',').filter(id => id);
// 3. جلب قائمة مدونات المستخدم من بلوجر
const blogsResp = await gapi.client.blogger.blogs.listByUser({ userId: 'self' });
const userBlogs = blogsResp.result.items || [];
// 4. المقارنة وتصفية النتائج
const activatedUserBlogs = userBlogs.filter(blog => activatedIds.includes(blog.id));
// 5. عرض النتائج
displayActivatedBlogs(activatedUserBlogs);
} catch (err) {
// التعامل مع الأخطاء المحتملة
const errorMessage = (err.result && err.result.error) ? err.result.error.message : err.toString();
showResult('error', `حدث خطأ: ${errorMessage}`);
}
}
// --- دوال مساعدة لعرض الواجهة ---
function displayActivatedBlogs(blogs) {
const list = document.getElementById('activated-blogs-list');
const messageDiv = document.getElementById('result-message');
messageDiv.style.display = 'none';
list.innerHTML = '';
if (!blogs || blogs.length === 0) {
list.innerHTML = '<li><p class="message info">لا توجد مدونات مفعلة مرتبطة بهذا الحساب حالياً.</p></li>';
return;
}
blogs.forEach(blog => {
const li = document.createElement('li');
li.innerHTML = `
<div class="blog-info">
<span class="blog-name">${blog.name}</span>
<span class="blog-id" title="اضغط لنسخ الـ ID">${blog.id}</span>
</div>
`;
// إضافة ميزة نسخ الـ ID عند الضغط عليه
li.querySelector('.blog-id').onclick = function() {
navigator.clipboard.writeText(this.textContent);
this.textContent = 'تم النسخ!';
setTimeout(() => { this.textContent = blog.id; }, 1500);
};
list.appendChild(li);
});
}
function showScreen(screenId) {
document.querySelectorAll('.app-screen').forEach(s => s.classList.remove('show'));
document.getElementById(screenId).classList.add('show');
}
function showResult(type, message) {
showScreen('result-screen');
const resultMessage = document.getElementById('result-message');
resultMessage.style.display = 'block';
resultMessage.className = `message ${type}`;
resultMessage.textContent = message;
document.getElementById('activated-blogs-list').innerHTML = '';
}
</script>
انا مهتم بمجال التقنية والربح من الانترنت واتطلع لنشر المزيد من المقالات التي تفيدكم
تعليقات
إرسال تعليق