Skip to content

Instantly share code, notes, and snippets.

@senritsu
Created September 15, 2016 06:35
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 senritsu/54cef09831a6a424d355e2c87a24fb46 to your computer and use it in GitHub Desktop.
Save senritsu/54cef09831a6a424d355e2c87a24fb46 to your computer and use it in GitHub Desktop.
Tampermonkey userscript to watch for Keyfalls in the invisible sun Kickstarter campaign
// ==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