Last active
September 3, 2020 00:00
-
-
Save xlash123/d0b5193b78f07a055ebcd902e0f34e41 to your computer and use it in GitHub Desktop.
Zoom Recording Playback Auto-Scroll Chat
This file contains 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
// Set this to the number of seconds off that the chat is from the video | |
var chatOffset = 0; | |
const vid = $('video'); | |
const chat = $('.zm-scrollbar__view ul'); | |
const messages = chat.querySelectorAll('li .chat-time'); | |
let lastTime = undefined; | |
function pad(num) { | |
return String(num).padStart(2, '0'); | |
} | |
function parseTime(str) { | |
const nums = /(\d\d)?:?(\d\d):(\d\d)/.exec(str); | |
let time = 0; | |
if (nums[1]) { | |
time = parseInt(nums[1]) * 60 * 60; | |
} | |
time += parseInt(nums[2]) * 60 + parseInt(nums[3]); | |
return time; | |
} | |
function viewChat(msg) { | |
msg.parentElement.parentElement.scrollIntoView({ | |
behavior: 'smooth', | |
block: 'end' | |
}); | |
} | |
vid.addEventListener('timeupdate', (e) => { | |
const time = Math.floor(vid.currentTime + chatOffset); | |
if (lastTime !== time) { | |
lastTime = time; | |
const sec = pad(time % 60); | |
const min = pad(Math.floor(time / 60) % 60); | |
const hour = pad(Math.floor(time / 60 / 60)); | |
let low = 0, high = messages.length - 1; | |
while (low <= high) { | |
let i = Math.floor(low + (high - low) / 2); | |
const msg = messages[i]; | |
const timeStr = `${hour !== '00' ? hour + ':' : ''}${min}:${sec}`; | |
if (msg.textContent === timeStr) { | |
viewChat(msg); | |
return; | |
} else { | |
const mtime = parseTime(msg.textContent); | |
if (time > mtime) { | |
low = i + 1; | |
} else { | |
high = i - 1; | |
} | |
} | |
} | |
if (high >= 0) | |
viewChat(messages[high]); | |
} | |
}); |
This file contains 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
var chatOffset=0;const vid=$("video"),chat=$(".zm-scrollbar__view ul"),messages=chat.querySelectorAll("li .chat-time");let lastTime=void 0;function pad(t){return String(t).padStart(2,"0")}function parseTime(t){const e=/(\d\d)?:?(\d\d):(\d\d)/.exec(t);let a=0;return e[1]&&(a=60*parseInt(e[1])*60),a+=60*parseInt(e[2])+parseInt(e[3])}function viewChat(t){t.parentElement.parentElement.scrollIntoView({behavior:"smooth",block:"end"})}vid.addEventListener("timeupdate",t=>{const e=Math.floor(vid.currentTime+chatOffset);if(lastTime!==e){lastTime=e;const t=pad(e%60),a=pad(Math.floor(e/60)%60),n=pad(Math.floor(e/60/60));let s=0,o=messages.length-1;for(;s<=o;){let r=Math.floor(s+(o-s)/2);const i=messages[r],l=`${"00"!==n?n+":":""}${a}:${t}`;if(i.textContent===l)return void viewChat(i);e>parseTime(i.textContent)?s=r+1:o=r-1}o>=0&&viewChat(messages[o])}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to Use
Open your dev tools (F12 is most browsers), go to the console tab, and paste in the above snippet (.min.js is recommended). Press enter once you see that the Zoom Chat window on the right has appeared.
Updates
Update 6/7/2020 @ 11:09PM EST:
Uses binary search to select chat item. Fixed chat not scrolling after past 1 hour mark. Chat scrolls to the previous message at a timestamp where there is no message.
Update 8/30/2020:
Sometimes the chat and video timestamps won't line up, so you can set
chatOffset
in either the source code or in the console to the number of seconds off that chat is from the video.