Last active
June 26, 2017 19:56
-
-
Save sineau/b71ef42a8d6d85d33fa7fac6d8fc42a7 to your computer and use it in GitHub Desktop.
Reschedule Notifier
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 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