From 5ccb8518e9be0abcbdc46deafb0eb1d2bbc4ef9e Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Mon, 13 Apr 2020 17:23:08 +0200 Subject: [PATCH] hack in an appendChild listener --- static/js/codex.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/static/js/codex.js b/static/js/codex.js index 4b0c188..c9ffc3e 100644 --- a/static/js/codex.js +++ b/static/js/codex.js @@ -67,20 +67,14 @@ $(function() { $('.sidebar-content').css('height', (height + 50) + 'px'); }; - var hijackAppendChildToExecuteAfter = function(afterFn) { + var hijackAppendChildToExecuteAfter = function(afterFn, elId) { const _appendChild = Node.prototype.appendChild; - const _replaceChild = Node.prototype.replaceChild; Node.prototype.appendChild = function(el) { _appendChild.apply(this, arguments); - console.log('appending ' + el); - afterFn(); - } - - Node.prototype.replaceChild = function(el) { - _replaceChild.apply(this, arguments); - console.log('replacing ' + el); - afterFn(); + if(el.id === elId) { + setTimeout(afterFn, 100); + } } } @@ -93,6 +87,6 @@ $(function() { resizeSidebar(); // needed for Commento, no 'official' callback when done provided. - hijackAppendChildToExecuteAfter(resizeSidebar); + hijackAppendChildToExecuteAfter(resizeSidebar, 'commento-footer'); });