Skip to content

Instantly share code, notes, and snippets.

@theshane
Created June 3, 2019 13:21
Show Gist options
  • Save theshane/9be06acd19db6adea60f8997fa51ab5c to your computer and use it in GitHub Desktop.
Save theshane/9be06acd19db6adea60f8997fa51ab5c to your computer and use it in GitHub Desktop.
Michigan Campsite Watcher (Need Tampermonkey for Chrome)
// ==UserScript==
// @name Mi Campsite Watcher
// @namespace https://www.midnrreservations.com/create-booking
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.midnrreservations.com/create-booking/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const items = {...localStorage};
Object.keys(items).forEach((key) => localStorage.removeItem(key));
setTimeout(() => {
const avail = document.getElementsByClassName("maplink available");
if (avail.length) {
notifyMe(avail.length + ' Sites available');
}
},5000)
setTimeout(() => {
window.location.reload();
},180000);
})();
function notifyMe(text) {
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
var notification = new Notification(text);
}
// Otherwise, we need to ask the user for permission
else if (Notification.permission !== "denied") {
Notification.requestPermission().then(function (permission) {
// If the user accepts, let's create a notification
if (permission === "granted") {
var notification = new Notification("Hi there!");
}
});
}
// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment