Skip to content

Instantly share code, notes, and snippets.

@sineau
Last active June 26, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sineau/b71ef42a8d6d85d33fa7fac6d8fc42a7 to your computer and use it in GitHub Desktop.
Save sineau/b71ef42a8d6d85d33fa7fac6d8fc42a7 to your computer and use it in GitHub Desktop.
Reschedule Notifier
// ==UserScript==
// @name rescheduleNotifier
// @namespace reaisus
// @include about:addons
// @include https://ais.usvisa-info.com/*/niv/schedule/*/payment
// @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()
var desiredTime = new Date(2016, 8, 30)
console.log(desiredTime)
function notifyMe (city, time) {
var notif = true
if (Notification.permission !== "denied")
Notification.requestPermission(function (permit) {
if (permit === "granted") var notif = new Notification(city + ": " + time)
})
else if (Notification.permission === "granted")
var notif = new Notification(city + ": " + time)
if (notif) {
notifPlayer.play()
setTimeout(setInterval(function() {
notifPlayer.play()
}, 30000), 2* 60 * 60 * 1000)
}
}
var scheduleTable = $(".ui-datepicker-calendar").find('[data-month="6"]')[0].textContent
console.log(scheduleTable)
if (scheduleTable.length !== 0) {
notifyMe(scheduleTable[0].city, scheduleTable[0].time)
} 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