Last active
September 8, 2018 18:31
-
-
Save phts/8bfdcb29a953f8d5764e70f1a35c110f to your computer and use it in GitHub Desktop.
Automatically check available visits in Luxmed
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== | |
// @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