Created
April 8, 2013 19:06
-
-
Save 100ideas/5339530 to your computer and use it in GitHub Desktop.
Javascript function to play a noise every time someone backs a particular kickstarter project. Works with the Kickstarter Status Board [1]. Paste code into the console when viewing the board and crank your speakers. Code by Jesse Farmer (https://github.com/jfarmer). [1]https://chrome.google.com/webstore/detail/kickstarter-status-board/pbbbkenlhf…
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
var BackerPoller = function() { | |
this.currentCount = this.scanCount(); | |
this.audioElement = document.createElement('audio'); | |
this.audioElement.setAttribute('src', 'https://dl.dropbox.com/u/3736314/kickstarter_backer_poller/kickbacker.wav'); | |
} | |
BackerPoller.prototype.scanCount = function() { | |
return $('.project-stats li:nth-child(3)').text().match(/\d+/)[0]; | |
} | |
BackerPoller.prototype.hasCountChanged = function() { | |
return this.currentCount != this.scanCount(); | |
} | |
BackerPoller.prototype.startPolling = function() { | |
var that = this; | |
if (this.hasCountChanged()) { | |
this.currentCount = this.scanCount(); | |
this.audioElement.play(); | |
} | |
setTimeout(function() { that.startPolling(); }, 1000); | |
} | |
var poller = new BackerPoller(); | |
poller.startPolling(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment