Last active
October 14, 2016 16:18
-
-
Save sineau/a21a31dc10724e30310cb2c2b8d313c2 to your computer and use it in GitHub Desktop.
This file contains 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== | |
// @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