Created
October 26, 2019 16:42
-
-
Save scriptify/3e745e4b1dcd2ac3166ac35c37fef386 to your computer and use it in GitHub Desktop.
If you find out what it's doing, it can be pretty useful...
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
const audioCtx = new (window.AudioContext || window.webkitAudioContext || window.audioContext); | |
function beep(duration, frequency, volume, type, callback) { | |
const oscillator = audioCtx.createOscillator(); | |
const gainNode = audioCtx.createGain(); | |
oscillator.connect(gainNode); | |
gainNode.connect(audioCtx.destination); | |
if (volume){gainNode.gain.value = volume;}; | |
if (frequency){oscillator.frequency.value = frequency;} | |
if (type){oscillator.type = type;} | |
if (callback){oscillator.onended = callback;} | |
oscillator.start(); | |
setTimeout(function(){oscillator.stop()}, (duration ? duration : 500)); | |
} | |
function watch() { | |
const inter = window.setInterval(() => { | |
const foundElem = document.querySelector('span[title="online"]'); | |
if (foundElem) { | |
beep(500, 500, 1, 'sine') | |
} | |
}, 500); | |
return () => { | |
window.clearInterval(inter); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment