Skip to content

Instantly share code, notes, and snippets.

@reduardo7
Created May 29, 2019 14:20
Show Gist options
  • Save reduardo7/8d65fa079250775a6517b01d87d77dfd to your computer and use it in GitHub Desktop.
Save reduardo7/8d65fa079250775a6517b01d87d77dfd to your computer and use it in GitHub Desktop.
Userscripts for Greasemonkey/Tampermonkey

Userscripts for Greasemonkey/Tampermonkey

// ==UserScript==
// @name MeetSub
// @namespace https://about.me/eduardo.cuomo.ar
// @version 1.0
// @description Google Meet Subtitles
// @author Eduardo Daniel Cuomo <eduardo.cuomo.ar@gmail.com | reduardo7@gmail.com>
// @match https://meet.google.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var subtitleDiv = null;
function getSubtitleDiv() {
//subtitleDiv = document.querySelector('div > div > div:nth-child(3) > div:nth-child(2) > div.QiOq5b');
subtitleDiv = document.querySelector('div > div > div:nth-child(3) > div:nth-child(2) > div:nth-child(5)');
return subtitleDiv;
}
function apply() {
subtitleDiv.style.position = 'absolute';
subtitleDiv.style.top = '0';
subtitleDiv.style.background = '#00000022';
subtitleDiv.style['text-shadow'] = '0 0 5px #000000';
// Watcher
if (window._resizeInterval) {
clearInterval(window._resizeInterval);
}
window._resizeInterval = setInterval(() => {
var participantsDiv = document.querySelector('div > div > div:nth-child(3) > div:nth-child(2) > div:nth-child(1) > div > div');
participantsDiv.style.top = subtitleDiv.offsetHeight + 'px';
participantsDiv.style.bottom = '100px';
}, 100);
}
function init() {
// Wait for subtitle div
if (getSubtitleDiv()) {
// Found, apply reformat
apply();
} else {
// Not found, retry...
setTimeout(init, 1000);
}
}
init();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment