Created
March 25, 2014 03:19
-
-
Save alexdresko/9754645 to your computer and use it in GitHub Desktop.
Greasemonkey/tampermonkey script that plays a sound whenever a matched page is finished loading.
This file contains hidden or 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 Soundy | |
// @namespace http://www.alexdresko.com/ | |
// @version 0.1 | |
// @description Plays some kind of noise whenever a matched page finishes loading | |
// @match https://localhost:44300/* | |
// @match https://gist.github.com/* | |
// @copyright 2014+, Alex Dresko | |
// ==/UserScript== | |
var beep = (function () { | |
var ctx = new(window.audioContext || window.webkitAudioContext); | |
return function (duration, type, finishedCallback) { | |
duration = +duration; | |
// Only 0-4 are valid types. | |
type = (type % 5) || 0; | |
if (typeof finishedCallback != "function") { | |
finishedCallback = function () {}; | |
} | |
var osc = ctx.createOscillator(); | |
osc.type = type; | |
osc.connect(ctx.destination); | |
osc.noteOn(0); | |
setTimeout(function () { | |
osc.noteOff(0); | |
finishedCallback(); | |
}, duration); | |
}; | |
})(); | |
setTimeout(function(){beep()},1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typo: window.audioContext should be window.AudioContext
Edit: Type is wrong also, you need to send it a string not a number.