XAM Notice
// ==UserScript==
// @name XAM Notification
// @namespace XAM
// @version 6.9
// @description auto púh notice
// @author hungvt89
// @match https://xamvn.run/*
// @grant GM_getValue
// @grant GM_setValue
// @icon data:image/webp;base64,UklGRrIBAABXRUJQVlA4WAoAAAAQAAAAGwAAGwAAQUxQSI4AAAARV6C2jSQ1eDnfxc/8ERGgI2GWv1PAaWzbrnJ+/vL9HlDYh0LlUAYahUSiXwPMReV02ny5g4j+TwCyz1erSciDNAHHL3nd+m4keUijhrA9nZ7ZJQzniNlq9aUZeQC8aRD4ICki8i8BqCe91o2JThEtAMw+rl1p4eHq4VQfktOhcOEtlDFCDYJ1xC9C67DUVlA4IP4AAACQBwCdASocABwAPtE+tFooIigoFAEAGglsAJ0yhHAwgrazwrwwH6m/qr2APJA6wDnzPYkAYsWSivx/YmItR+B77EJQrAAA/c0uRf3OBLi0BAdtubdzRvY4Xagg+CV6UzuEiXIM7etulMrcBCD/QK60cDAFYV7p+hRWX5VfuOssKJVXjMSX74Sg+ukoya1l/fGV/PTuPCXdVYvkoHu3U7rV2iaO/G7yrf0/f3AQR+WfhonYg+s7SGTt3P/6t+FkxQdlOMOTxXl1xev9XOFGHg3157B7va3TGV9r4n4fgLDjI//+tCmGd0AyAV/Pn8yxoFGDtq6KJLen0SU39nogAA==
// ==/UserScript==
(function() {
'use strict';
let Delay=10000; // SỬA THÀNH SỐ MILI GIÂY DELAY RELOAD PAGE , VÍ DỤ 3000,5000...60000
let KeepNotification=true // THÔNG BÁO SẼ KHÔNG ẨN ĐẾN KHI MÀY ẤN VÀO,
//sửa thành false nếu muốn nó tự ẩn .
//chấm hết
let currentBadgeValue = GM_getValue('currentBadgeValue', null);
function showNotification(title, message) {
if (Notification.permission === "granted") {
new Notification(title, {
body: message,
requireInteraction: KeepNotification
});
} else if (Notification.permission !== "denied") {
Notification.requestPermission().then(function(permission) {
if (permission === "granted") {
showNotification(title, message);
}
});
}
}
function checkBadgeAndNotify() {
const alertLink = document.querySelector('a[href="/account/alerts"]');
if (alertLink) {
const newBadgeValue = alertLink.dataset.badge;
if (currentBadgeValue !== null &&newBadgeValue != '0'&& newBadgeValue !== currentBadgeValue) {
showNotification("XAMVN","Ê KU")
}
currentBadgeValue = newBadgeValue;
GM_setValue('currentBadgeValue', currentBadgeValue);
}
}
let loadstart = null;
if (!document.hasFocus()) {
loadstart = setTimeout(() => {
if (!document.hasFocus()) {
location.reload();
}
}, Delay);
}
window.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
loadstart = setTimeout(() => {
if (document.visibilityState === 'hidden') {
location.reload();
}
}, Delay);
} else if (document.visibilityState === 'visible') {
if (loadstart) {
clearTimeout(loadstart);
loadstart = null;
}
}
});
checkBadgeAndNotify();
})();
Public Last updated: 2024-07-12 12:42:01 PM