Last active
January 26, 2026 22:20
-
-
Save MoatazAbdAlmageed/b5014bdd30c85bc637682c6483854ea2 to your computer and use it in GitHub Desktop.
My we (Sound notifications for new database rows) for UserScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name WE Chat Notifier | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2026-01-27 | |
| // @description Sound notification for new customer service messages | |
| // @author You | |
| // @match https://my.te.eg/echannel/ | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=te.eg | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // تعريف المراقب كمتغير عام | |
| let observer = null; | |
| // دالة لبدء المراقبة | |
| function startChatMonitoring() { | |
| const chatContainer = document.getElementById('the-chat-container'); | |
| if (!chatContainer) { | |
| console.log('⚠️ حاوية الشات غير موجودة بعد'); | |
| return; | |
| } | |
| // إذا كان المراقب يعمل بالفعل، لا تبدأ مراقب جديد | |
| if (observer) { | |
| console.log('⚠️ المراقبة تعمل بالفعل'); | |
| return; | |
| } | |
| observer = new MutationObserver((mutations) => { | |
| mutations.forEach((mutation) => { | |
| mutation.addedNodes.forEach((node) => { | |
| if (node.nodeType === 1 && node.tagName === 'DIV') { | |
| // تجاهل رسائل العميل | |
| if (node.classList.contains('msg-client')) { | |
| return; | |
| } | |
| // التنبيه لرسائل خدمة العملاء | |
| if (node.classList.contains('msg-sender') || node.querySelector('.msg-sender')) { | |
| const messageText = node.textContent || node.innerText; | |
| // تجاهل الرسائل التي تحتوي على "أمامك" | |
| if (messageText.includes('أمامك')) { | |
| console.log('⏭️ تم تجاهل رسالة "أمامك"'); | |
| return; | |
| } | |
| // تشغيل صوت التنبيه | |
| const audio = new Audio('https://assets.mixkit.co/active_storage/sfx/2869/2869-preview.mp3'); | |
| audio.play(); | |
| console.log('🔔 رسالة جديدة من خدمة العملاء!'); | |
| } | |
| } | |
| }); | |
| }); | |
| }); | |
| observer.observe(chatContainer, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| console.log('✅ بدأت مراقبة الشات'); | |
| } | |
| // الانتظار حتى تحميل الصفحة بالكامل | |
| window.addEventListener('load', function() { | |
| // محاولة ربط الزر | |
| const startButton = document.getElementById('start-chat-landing'); | |
| if (startButton) { | |
| startButton.addEventListener('click', function() { | |
| // انتظار قليل للتأكد من تحميل حاوية الشات | |
| setTimeout(startChatMonitoring, 1000); | |
| }); | |
| console.log('👂 في انتظار الضغط على زر البدء...'); | |
| } else { | |
| console.log('⚠️ زر البدء غير موجود'); | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment