hand raised
This commit is contained in:
@@ -466,6 +466,10 @@
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.politictalk-hidden-av-request {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
html:not(.politictalk-direct-access-blocked),
|
||||
html:not(.politictalk-direct-access-blocked) body,
|
||||
@@ -1144,6 +1148,141 @@
|
||||
});
|
||||
}
|
||||
|
||||
function normalizePoliticTalkText(value) {
|
||||
return String(value || '').replace(/\s+/g, ' ').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function isPoliticTalkModerationAction(text) {
|
||||
return text.indexOf('allow audio') !== -1
|
||||
|| text.indexOf('allow video') !== -1
|
||||
|| text.indexOf('allow screen sharing') !== -1
|
||||
|| text.indexOf('allow all') !== -1
|
||||
|| text.indexOf('unmute audio') !== -1
|
||||
|| text.indexOf('unmute video') !== -1
|
||||
|| text.indexOf('start screen sharing') !== -1;
|
||||
}
|
||||
|
||||
function findPoliticTalkNotificationCard(element) {
|
||||
var current = element;
|
||||
|
||||
while (current && current !== document.body) {
|
||||
if (isPoliticTalkRaisedHandCard(current)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current = current.parentElement;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function isPoliticTalkRaisedHandCard(element) {
|
||||
if (!element || element === document.body) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var text = normalizePoliticTalkText(element.textContent);
|
||||
var rect = element.getBoundingClientRect();
|
||||
|
||||
return text.indexOf('would like to participate') !== -1
|
||||
&& rect.width > 120
|
||||
&& rect.width < 560
|
||||
&& rect.height > 40
|
||||
&& rect.height < 280;
|
||||
}
|
||||
|
||||
function applyPoliticTalkModerationNotificationPolicy() {
|
||||
if (directAccessBlocked || !document.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
var isHost = isPoliticTalkHost();
|
||||
var controls = document.querySelectorAll('button, [role="button"], a');
|
||||
var handledCards = [];
|
||||
|
||||
controls.forEach(function(control) {
|
||||
var actionText = normalizePoliticTalkText([
|
||||
control.getAttribute('aria-label'),
|
||||
control.getAttribute('title'),
|
||||
control.textContent
|
||||
].join(' '));
|
||||
|
||||
if (!isPoliticTalkModerationAction(actionText)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var card = findPoliticTalkNotificationCard(control);
|
||||
|
||||
if (!card || handledCards.indexOf(card) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
handledCards.push(card);
|
||||
|
||||
var cardText = normalizePoliticTalkText(card.textContent);
|
||||
var isAudioCard = cardText.indexOf('allow audio') !== -1
|
||||
|| cardText.indexOf('unmute audio') !== -1;
|
||||
var isVideoOrDesktopCard = cardText.indexOf('allow video') !== -1
|
||||
|| cardText.indexOf('allow screen sharing') !== -1
|
||||
|| cardText.indexOf('unmute video') !== -1
|
||||
|| cardText.indexOf('start screen sharing') !== -1;
|
||||
|
||||
card.classList.toggle('politictalk-hidden-av-request', !isHost || isVideoOrDesktopCard || !isAudioCard);
|
||||
card.setAttribute('aria-hidden', (!isHost || isVideoOrDesktopCard || !isAudioCard) ? 'true' : 'false');
|
||||
|
||||
card.querySelectorAll('button, [role="button"], a').forEach(function(cardControl) {
|
||||
var cardControlText = normalizePoliticTalkText([
|
||||
cardControl.getAttribute('aria-label'),
|
||||
cardControl.getAttribute('title'),
|
||||
cardControl.textContent
|
||||
].join(' '));
|
||||
|
||||
if (cardControlText.indexOf('allow all') !== -1) {
|
||||
cardControl.classList.add('politictalk-hidden-av-request');
|
||||
cardControl.setAttribute('aria-hidden', 'true');
|
||||
cardControl.setAttribute('tabindex', '-1');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (!isHost) {
|
||||
document.querySelectorAll('[role="alert"], [class*="notification"], [class*="Notification"], div')
|
||||
.forEach(function(candidate) {
|
||||
if (isPoliticTalkRaisedHandCard(candidate)) {
|
||||
candidate.classList.add('politictalk-hidden-av-request');
|
||||
candidate.setAttribute('aria-hidden', 'true');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function mountPoliticTalkModerationNotificationPolicy() {
|
||||
applyPoliticTalkModerationNotificationPolicy();
|
||||
|
||||
if (window.politicTalkModerationNotificationObserver || !document.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.politicTalkModerationNotificationObserver = new MutationObserver(function() {
|
||||
window.cancelAnimationFrame(window.politicTalkModerationNotificationFrame);
|
||||
window.politicTalkModerationNotificationFrame = window.requestAnimationFrame(
|
||||
applyPoliticTalkModerationNotificationPolicy
|
||||
);
|
||||
});
|
||||
window.politicTalkModerationNotificationObserver.observe(document.body, {
|
||||
attributes: true,
|
||||
attributeFilter: [ 'aria-label', 'class', 'style', 'title' ],
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
window.clearInterval(window.politicTalkModerationNotificationInterval);
|
||||
window.politicTalkModerationNotificationInterval = window.setInterval(function() {
|
||||
applyPoliticTalkModerationNotificationPolicy();
|
||||
}, 800);
|
||||
}
|
||||
|
||||
function mountPoliticTalkLogo() {
|
||||
if (!document.body || document.getElementById('politictalk-room-logo')) {
|
||||
return;
|
||||
@@ -1222,6 +1361,7 @@
|
||||
mountHostHangupPolicy();
|
||||
mountMobileToolbarPositioning();
|
||||
mountPoliticTalkStageBrandInset();
|
||||
mountPoliticTalkModerationNotificationPolicy();
|
||||
});
|
||||
} else {
|
||||
mountPoliticTalkDocumentTitle();
|
||||
@@ -1230,6 +1370,7 @@
|
||||
mountHostHangupPolicy();
|
||||
mountMobileToolbarPositioning();
|
||||
mountPoliticTalkStageBrandInset();
|
||||
mountPoliticTalkModerationNotificationPolicy();
|
||||
}
|
||||
}());
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user