Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This script will alert you with text to speech
- when a target user is goes online inside your discord server.
- */
- var alert_flags = [];
- const targets = {
- "ᴶᵉˢˢ": {
- "tts_msg": "Jessica is active."
- },
- "Twink": {
- "tts_msg": "Jadie has active."
- }
- };
- function getNames() {
- var names = [];
- const collection = document.getElementsByClassName("name-uJV0GL");
- for (x = 0; x < collection.length; x++) {
- names.push(collection[x].textContent);
- }
- return names;
- }
- setInterval(function() {
- for (t = 0; t < Object.keys(targets).length; t++) {
- if (!alert_flags.includes(Object.keys(targets)[t])) {
- if (getNames().includes(Object.keys(targets)[t])) {
- alert_flags.push(Object.keys(targets)[t]);
- var tts_alert = new SpeechSynthesisUtterance(targets[Object.keys(targets)[t]]["tts_msg"]);
- window.speechSynthesis.speak(tts_alert);
- }
- }
- }
- for (y = 0; y < alert_flags.length; y++) {
- if (!getNames().includes(alert_flags[y])) {
- alert_flags.pop(alert_flags[y]);
- }
- }
- }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement