Files
WVUMedicine-HAWebClient/src/inject.js
T

49 lines
1.9 KiB
JavaScript

(function () {
var originalOpen = window.open;
window.open = function (url) {
if (url) { window.location.href = url; return null; }
return originalOpen.apply(this, arguments);
};
if (window.location.href.includes('/ha') || window.location.href.includes('helpalert.html')) {
if (Notification.permission === 'default') {
Notification.requestPermission();
}
var seenAlerts = {};
setInterval(function () {
if (!document.body) return;
var text = document.body.innerText;
var currentAlerts = {};
var lines = text.split('\n');
for (var i = 0; i < lines.length; i++) {
if (lines[i].trim().startsWith('Geo:') && i > 0) {
var name = lines[i - 1].trim();
if (name && name !== 'Claim' && name !== 'VIDEO') {
currentAlerts[name] = true;
}
}
}
for (var key in currentAlerts) {
if (!seenAlerts[key]) {
console.log('[DuressGuard] NEW ALERT:', key);
if (window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__.invoke('alert_detected', { name: key });
}
try {
var ctx = new AudioContext();
var osc = ctx.createOscillator();
var gain = ctx.createGain();
osc.connect(gain);
gain.connect(ctx.destination);
osc.frequency.value = 800;
gain.gain.value = 0.3;
osc.start();
osc.stop(ctx.currentTime + 0.5);
} catch (e) { }
}
}
seenAlerts = currentAlerts;
}, 2000);
}
})();;