changed xpath and observer to work with two-column table

This commit is contained in:
2021-10-31 14:06:19 +01:00
parent 20e08895d1
commit fb1ed4145e
+31 -2
View File
@@ -24,7 +24,7 @@ JWConfZoomHand
var JWConfRaisings = 0;
// loop through table of attendees and call for observer subscription
function subscribeNewAttendees() {
/* function subscribeNewAttendees() {
if (signalEnabled === false) {
return;
}
@@ -35,10 +35,39 @@ JWConfZoomHand
addObserver(row);
}
}
} */
function subscribeNewAttendees() {
if (signalEnabled === false) {
return;
}
var tablesAttendees = document.evaluate('//table[starts-with(@class,"listener-table")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
var tableAttendees = null;
for ( var i=0; i < tablesAttendees.snapshotLength; i++ )
{
tableAttendees = tablesAttendees.snapshotItem(i)
for (var i = 0, row; row = tableAttendees.rows[i]; i++) {
if (row.parentNode.localName !== "thead") {
addObserver(row);
}
}
}
}
/*
wegen unten XPathResult.ORDERED_NODE_ITERATOR_TYPE durch XPathResult.ORDERED_NODE_SNAPSHOT_TYPE ersetzt (
siehe https://developer.mozilla.org/en-US/docs/Web/API/Document/evaluate
Results of NODE_SNAPSHOT types are snapshots, which are essentially lists of matched nodes. You can make changes to the document by altering snapshot nodes. Modifying the document doesn't invalidate the snapshot; however, if the document is changed, the snapshot may not correspond to the current state of the document, since nodes may have moved, been changed, added, or removed.
führt leider manchmal zu
jwconfsignal.js:46 Uncaught DOMException: Failed to execute 'iterateNext' on 'XPathResult': The document has mutated since the result was returned.
at subscribeNewAttendees (chrome-extension://hhcadpapjmemfpokloljohmahipbjhmb/jwconfsignal.js:46:42)
at chrome-extension://hhcadpapjmemfpokloljohmahipbjhmb/jwconfsignal.js:250:4 */
function updateJWConfRaisings() {
JWConfRaisings = document.evaluate('count(//table[@class="listener-table"]//tr[@class="detected speechrequest"])', document, null, XPathResult.ANY_TYPE, null ).numberValue;
//JWConfRaisings = document.evaluate('count(//table[starts-with(@class,"listener-table")]//tr[@class="speechrequest detected"])', document, null, XPathResult.ANY_TYPE, null ).numberValue;
JWConfRaisings = document.evaluate('count(//table[starts-with(@class,"listener-table")]//tr[@class="detected speechrequest" or @class="speechrequest detected" or @style="background-color: rgb(23, 121, 186); color: rgb(254, 254, 254);" or @style="background-color: rgb(161, 184, 105); color: rgb(254, 254, 254);"])', document, null, XPathResult.ANY_TYPE, null ).numberValue;
}
function subscribeAttList() {