Skip to content

Instantly share code, notes, and snippets.

@sreyemnayr
Last active September 13, 2020 21:15
Show Gist options
  • Save sreyemnayr/ca14c46ab374a9f1055de13e4097d1bd to your computer and use it in GitHub Desktop.
Save sreyemnayr/ca14c46ab374a9f1055de13e4097d1bd to your computer and use it in GitHub Desktop.
;(function () {
let participantsList = new Set();
Do()
function Do() {
setInterval(() => {
if (window.default_MeetingsUi) {
if (!window.default_MeetingsUi.__hooked) {
const p = new Proxy(window.default_MeetingsUi, __window__default_MeetingsUi())
p.__hooked = true
window.default_MeetingsUi = p
}
}
}, 1000)
function __window__default_MeetingsUi() {
return {
set: function (obj, prop, value) {
if (value && typeof value === 'function') {
const m = /\.([A-Za-z]+)\([a-zA-Z,.]+\{[^\x05]*?this\.([A-Za-z]+)=[A-Za-z]+\(this\)/.exec(value.toString())
if (m) {
value = new Proxy(value, __refreshVideo(m[2], m[1]))
}
}
return Reflect.set(obj, prop, value)
},
}
}
function __refreshVideo(objKey, funcKey) {
return {
construct: function (target, argumentsList) {
const ret = Reflect.construct(target, argumentsList)
ret[objKey] = new Proxy(ret[objKey], __layoutVideo(ret, funcKey))
return ret
},
}
}
function __layoutVideo(parent, funcKey) {
return {
get: function (target, name) {
let ret = Reflect.get(target, name)
if (typeof ret === 'function') {
ret = ret.bind(target)
}
if (name == 'get') {
return idx => ({
[funcKey]: (videoOrdering, windowData) => {
try {
ReportParticipants.call(parent, videoOrdering, windowData)
return ret(idx)[funcKey](videoOrdering, windowData)
} catch (e) {
console.error(e)
return ret(idx)[funcKey](videoOrdering, windowData)
}
},
})
}
return ret
},
}
}
function ReportParticipants(o) {
const isSpacesStr = i => typeof i === 'string' && i.startsWith('spaces/')
const participantObject = Object.values(this).find(v => v && v.constructor && /listener=new/.test(v.constructor.toString()))
const participantKeys = Object.values(participantObject).find(v => Array.isArray(v) && v.length && v.every(isSpacesStr)) || []
const participantsMap = Object.values(participantObject).find(v => v instanceof Map && v.size && Array.from(v.keys()).every(isSpacesStr))
let participantsListNow = new Set()
for (const v of participantKeys) {
participantsListNow.add(participantsMap.get(v).name)
}
if (!isSuperset(participantsListNow, participantsList) || !isSuperset(participantsList, participantsListNow)) {
participantsList = participantsListNow
console.log("Change in participants")
console.log(participantsList)
}
return o
}
}
function isSuperset(set, subset) {
for (let elem of subset) {
if (!set.has(elem)) {
return false
}
}
return true
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment