Skip to content

Instantly share code, notes, and snippets.

@jeansordes
Last active February 9, 2022 10:24
Show Gist options
  • Save jeansordes/2e87d589de759d5638ab3aec97e33eb0 to your computer and use it in GitHub Desktop.
Save jeansordes/2e87d589de759d5638ab3aec97e33eb0 to your computer and use it in GitHub Desktop.
Focusmate script : audio on new message + add a dashboard link in header
// ==UserScript==
// @name Focusmate : audio on new message + add a dashboard link in header
// @match https://www.focusmate.com/*
// @match https://focusmate.daily.co/*
// @source https://gist.github.com/jeansordes/2e87d589de759d5638ab3aec97e33eb0/raw
// ==/UserScript==
// you can deactivate the features you want from here
const activatedFeatures = {
'added_dashboard_btn': true,
'audio_on_new_msg': true,
// TODO book sessions with your favorite friends
// TODO make it a chrome extension
'debugging': false,
};
const _ = (...args) => {
if (activatedFeatures.debugging) {
console.log(...args);
}
}
// search until it finds its target, then run the callback on it
var currentSearches = []; // to avoid multiple searches of the same element
var searchForElement = (searchString, callback) => {
if (!currentSearches.includes(searchString)) {
_('>>> Searching for', searchString);
currentSearches.push(searchString);
var searchInterval = setInterval(() => {
// if we find the element, trigger callback
let el = document.querySelector(searchString);
if (el) {
_('!!! Found', searchString, '(stop searching)');
callback(el);
clearInterval(searchInterval);
currentSearches = currentSearches.filter(e => e != searchString);
}
}, 1000)
}
}
if (window != window.top) {
/**
* Trigger a ringtone on new messages in the chat
*/
if (activatedFeatures.added_dashboard_btn) {
// check if we are in an iframe (because the msg box is in an iframe)
var playSoundOnMutation = (elementToWatch) => {
const notificationSound = 'data:audio/mpeg;base64,SUQzAwAAAAAAIVRYWFgAAAAXAAAAU29mdHdhcmUATGF2ZjU4LjI5LjEwMP/7kEQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhpbmcAAAAPAAAAHgAAL48ACwsLERERFxcXFx8fHygoKDExMTE7OztERERNTU1NVlZWX19faGhoaHFxcXx8fIiIiJGRkZGampqjo6OjrKystbW1vr6+xsbGxs7OztbW1tbd3d3l5eXs7Oz09PT0/Pz8////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VVVVVVVVVVf/7gEToARJCHcv7DzI6ScRZj2HmO0j0gyvsPMrpbI/k9ZMmDFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tARPIP8hMdyPsMM6pHInjcYYZJAAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU=';
var player = document.createElement('audio');
player.src = notificationSound;
player.preload = 'auto';
var observer = new MutationObserver(() => {
console.log('✨ New message ✨');
player.currentTime = 0;
player.play();
});
observer.observe(elementToWatch, { childList: true, subtree: true });
// observer.disconnect();
}
// we search for the button that will open the chat,
// we configurate it so that it triggers the listening
// on new message, and then, we trigger it
searchForElement('#chat-controls', (chatCtrlBtn) => {
chatCtrlBtn.addEventListener('click', () => {
searchForElement('.messages-inner', (chatBox) => {
playSoundOnMutation(chatBox);
});
});
playSoundOnMutation(chatCtrlBtn);
chatCtrlBtn.click();
});
}
} else {
/**
* Add a "Dashboard" button at the top
*/
if (activatedFeatures.audio_on_new_msg) {
var addDashboardButton = () => {
// add the button only if it's not found
// and only if on focusmate.com/session/...
// (we don't need a dashboard button on other pages)
if (/session\//.test(document.location.href)
&& !document.getElementById('fm_dashboard_href')
) {
searchForElement('.is-controls-container', (header) => {
// CSS
let bodyStyle = document.createElement('style');
bodyStyle.innerHTML = `#fm_dashboard_href {
flex: 0;
padding: 0 1rem;
margin-left: 5px;
}
.is-timer {
padding-left: 8px;
}
`;
document.body.insertBefore(bodyStyle, document.body.childNodes[0]);
// separator
let separator = header.querySelector('.vertical-sep').cloneNode();
header.insertBefore(separator, header.childNodes[0]);
// Dashboard button
let els = document.createElement('div');
els.innerHTML = `<a id="fm_dashboard_href" class="fm-is-btn" `
+ `href="https://www.focusmate.com/dashboard" `
+ `target="_blank" >Dashboard</a>`;
header.insertBefore(els.childNodes[0], header.childNodes[0]);
});
}
}
// previous version triggered on history.pushState
// but was not reliable
// new version relies on body click
// to be extra sure it works
document.body.addEventListener('click', () => {
addDashboardButton();
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment