// ==UserScript==
// @name Nusuk Slot Alert Engine
// @namespace http://tampermonkey.net/
// @version 1.0
// @description مراقبة توفر المواعيد في منصة نسك وتنبيه المستخدم صوتياً وبصرياً
// @author Developer
// @match https://*.nusuk.sa/*
// @match https://*.haj.gov.sa/*
// @grant GM_notification
// ==/UserScript==
(function() {
'use strict';
// 1. وقت الانتظار بين كل تحديث (بالثواني) - يُفضل عدم تقليله عن 15 ثانية لتجنب الحظر
const REFRESH_INTERVAL = 15;
// 2. دالة تشغيل التنبيه الصوتي عبر Web Audio API (لا تتطلب ملفات خارجية)
function triggerAudioAlert() {
try {
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(880, audioCtx.currentTime); // تردد التنبيه (880Hz)
// نغمة متقطعة لتنفيخ الانتباه
gain.gain.setValueAtTime(1, audioCtx.currentTime);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 3); // تستمر 3 ثوانٍ
} catch (e) {
console.error("فشل تشغيل الصوت:", e);
}
}
// 3. دالة إرسال إشعار المتصفح
function sendBrowserNotification() {
if (Notification.permission === "granted") {
new Notification("🚨 تنبيه منصة نسك", {
body: "تم العثور على مواعيد متاحة! سارع بإتمام الحجز الآن.",
icon: "https://nusuk.sa/favicon.ico",
requireInteraction: true
});
}
}
// طلب إذن الإشعارات عند بدء تشغيل السكربت
if (typeof Notification !== "undefined" && Notification.permission !== "granted" && Notification.permission !== "denied") {
Notification.requestPermission();
}
// 4. دالة فحص العناصر داخل الصفحة
function checkSlots() {
// يمكنك إضافة أو تعديل العناصر (Selectors) بناءً على الكلاسات المستعملة في الواجهة
const selectors = [
'.slot-available',
'.available-date',
'[data-status="available"]',
'.badge-success',
'.green-slot'
];
let found = false;
// فحص وجود العناصر المعرفة
for (let selector of selectors) {
if (document.querySelector(selector)) {
found = true;
break;
}
}
// فحص البديل: البحث عن كلمات افتتاحية تدل على التوفر في محتوى الصفحة
const bodyText = document.body.innerText || "";
if (bodyText.includes("متاح") || bodyText.includes("أماكن متاحة") || bodyText.includes("Available")) {
// للتأكد من أنها ليست كلمة "غير متاح"
if (!bodyText.includes("غير متاح") && !bodyText.includes("لا يوجد مواعيد")) {
found = true;
}
}
if (found) {
console.log("%c [Nusuk Monitor] 🚨 تم العثور على موعد!", "color: green; font-size: 18px; font-weight: bold;");
triggerAudioAlert();
sendBrowserNotification();
document.title = "🚨 موعد متاح الآن! 🚨";
} else {
console.log(`[Nusuk Monitor] لا توجد مواعيد. إعادة الفحص خلال ${REFRESH_INTERVAL} ثانية...`);
setTimeout(() => {
location.reload();
}, REFRESH_INTERVAL * 1000);
}
}
// انتظر 3 ثوانٍ بعد استكمال تحميل الصفحة للتأكد من استقرار المكونات (DOM)
window.addEventListener('load', () => {
setTimeout(checkSlots, 3000);
});
})();
تعليقات
إرسال تعليق