Skip to content

Instantly share code, notes, and snippets.

@phts
Last active September 8, 2018 18:31
Show Gist options
  • Save phts/8bfdcb29a953f8d5764e70f1a35c110f to your computer and use it in GitHub Desktop.
Save phts/8bfdcb29a953f8d5764e70f1a35c110f to your computer and use it in GitHub Desktop.
Automatically check available visits in Luxmed
// ==UserScript==
// @author Phil Tsaryk
// @description Automatically check available visits in Luxmed
// @grant none
// @match https://portalpacjenta.luxmed.pl/PatientPortal/Reservations/Reservation/*
// @name Luxmed live
// @namespace https://github.com/phts/
// @version 1.1.1
// ==/UserScript==
function refresh() {
$('#reservationSearchSubmitButton').click()
}
function play() {
const sound = new Audio('http://s1download-universal-soundbank.com/mp3/sounds/2569.mp3')
sound.volume = 0.1
sound.play()
}
function notification() {
if (Notification.permission === 'granted') {
showNotification()
} else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === 'granted') {
showNotification()
}
})
}
}
function showNotification() {
const icon = 'https://portalpacjenta.luxmed.pl/PatientPortal/Content/css/theme/G/logo-en.png'
const options = {
icon,
}
return new Notification('Luxmed: Что-то изменилось', options)
}
const DELAY = 30000
const timeout = setTimeout(refresh, DELAY)
const newContent = $('#data-container').html().replace(/term-id="[^"]+"/g, '***')
const oldContent = localStorage.getItem('content')
if (oldContent !== null && newContent !== oldContent) {
clearTimeout(timeout)
play()
notification()
}
localStorage.setItem('content', newContent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment