From fb1ed4145e1000313ec13e41d23d707311ce07ae Mon Sep 17 00:00:00 2001 From: joel Date: Sun, 31 Oct 2021 14:06:19 +0100 Subject: [PATCH] changed xpath and observer to work with two-column table --- jwconfsignal.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/jwconfsignal.js b/jwconfsignal.js index 79268b4..edc2d4e 100644 --- a/jwconfsignal.js +++ b/jwconfsignal.js @@ -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() {