Created
September 15, 2016 06:35
-
-
Save senritsu/54cef09831a6a424d355e2c87a24fb46 to your computer and use it in GitHub Desktop.
Tampermonkey userscript to watch for Keyfalls in the invisible sun Kickstarter campaign
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 Invisible sun keyfall watcher | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description watches for keyfalls | |
// @author senritsu | |
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser-polyfill.min.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.min.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js | |
// @match https://www.kickstarter.com/projects/montecookgames/invisible-sun* | |
// ==/UserScript== | |
/* jshint ignore:start */ | |
var inline_src = (<><![CDATA[ | |
/* jshint ignore:end */ | |
/* jshint esnext: true */ | |
/* jshint asi: true */ | |
const reloadDelay = 30 | |
function setupWatcher() { | |
const css = document.createElement('link') | |
css.rel = 'stylesheet' | |
css.href = 'https://cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css' | |
document.head.appendChild(css) | |
const pledge = document.querySelector('li.pledge-selectable-sidebar[data-reward-id="5326811"]') | |
if(pledge.classList.contains('pledge--available')) { | |
const notification = new Notification('Keys available!') | |
} | |
NProgress.configure({ trickle: false, minimum: 0.01 }) | |
NProgress.start() | |
setInterval(() => { | |
NProgress.inc(1 / reloadDelay) | |
}, 1000) | |
setTimeout(() => location.reload(), reloadDelay * 1000) | |
} | |
if(Notification.permission != 'granted') { | |
Notification.requestPermission() | |
.then((permission) => { | |
if(permission == 'granted') { | |
setupWatcher() | |
} | |
}) | |
} else { | |
setupWatcher() | |
} | |
/* jshint ignore:start */ | |
]]></>).toString(); | |
var c = babel.transform(inline_src); | |
eval(c.code); | |
/* jshint ignore:end */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment