Last active
May 3, 2024 05:35
-
-
Save bushaev-denis/18cb57940430c3822693b9cbaff1ad37 to your computer and use it in GitHub Desktop.
Kdmid calendar notify has available record
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
const beep = () => { | |
const context = new AudioContext(); | |
const oscillator = context.createOscillator(); | |
oscillator.type = "sawtooth"; | |
oscillator.frequency.value = 1200; | |
oscillator.connect(context.destination); | |
oscillator.start(); | |
if (confirm('Появилась запись')) { | |
oscillator.stop(); | |
} | |
} | |
const randSeconds = (n, x) => Math.floor(Math.random() * (x * 1000 - n * 1000 + 1) + n * 1000); | |
const text = 'В настоящий момент на интересующее Вас консульское действие в системе предварительной записи нет свободного времени'.toLowerCase().replace(/\s+/g, ''); // text to find | |
const time = 60; // in sec | |
if (/\.kdmid\.ru\/queue\/SPCalendar\.aspx/.test(location.href)) { | |
const nodeText = document.querySelector('#desk #center-panel')?.textContent.toLowerCase().replace(/\s+/g, '') || ''; | |
if (!nodeText.includes(text)) { | |
console.log('found') | |
beep(); | |
} else { | |
console.log('start timer') | |
setTimeout(() => location.reload(), randSeconds(60, 90)) | |
} | |
}; |
Отвечая на комментарии, кнопку тут добавлять бесполезно (по крайней мере мне лень глубоко копать), но в данном случае я просто обновляю страницу и смотрю изменения текста. Поэтому вам каждый раз нужно было бы наживать эту кнопку. Я обновил сегодня код, он запускается сам, но единственное, что вам нужно сделать иначе от сайта загранников - обязательно включить звук для нужного вам домена, чтоб звуковое уведомление сработало.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
да я с ереванского скопировал часть кода с кнопкой где и вставил в этот но видимо это не требуется и все вроде работает
let started = false;
const buttonText = ['▶ запустить скрипт️', '⏸ остановить скрипт'];
const Button = document.createElement('button');
Button.style.cssText = 'position: fixed; top: 20px; left: 20px; font-size: 1.5rem';
Button.textContent = buttonText[0];
document.documentElement.appendChild(Button)
Button.addEventListener('click', () => {
started = !started;
Button.textContent = buttonText[Number(started)];
start();
})