Skip to content

Instantly share code, notes, and snippets.

@sineau
Last active October 14, 2016 16:18
Show Gist options
  • Save sineau/a21a31dc10724e30310cb2c2b8d313c2 to your computer and use it in GitHub Desktop.
Save sineau/a21a31dc10724e30310cb2c2b8d313c2 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name uscisNotifier
// @namespace uscis
// @include about:addons
// @include https://egov.uscis.gov/casestatus/mycasestatus.do?appReceiptNum=*
// @version 0.1
// @grant none
// ==/UserScript==
var notifPlayer = document.createElement('AUDIO')
notifPlayer.src = 'https://dl.dropbox.com/u/7079101/coin.mp3'
notifPlayer.preload = 'auto'
var date = new Date,
weekDays = ["Sunday", "Monday", "Tuesday", "Wednsday", "Thursday", "Friday", "Saturday"]
dateValues = weekDays[date.getDay()] + " - " + date.getHours()
+ ":" + date.getMinutes() + ":" + date.getSeconds()
function notifyMe (newMessage) {
var notif = true
if (Notification.permission !== "denied")
Notification.requestPermission(function (permit) {
if (permit === "granted") var notif = new Notification(newMessage)
})
else if (Notification.permission === "granted")
var notif = new Notification(newMessage)
if (notif) {
notifPlayer.play()
setTimeout(setInterval(function() {
notifPlayer.play()
}, 30000), 2* 60 * 60 * 1000)
}
}
var $status = $('.appointment-sec h1').html()
if ($status != 'Fingerprint Fee Was Received') notifyMe ($status)
else {
var timeOut = Math.random() * (300000 - 60000) + 60000
console.log(dateValues + "-- going for reload in " + timeOut)
setTimeout(function() {document.location.reload()}, timeOut)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment