diff options
-rw-r--r-- | view/js/main.js | 29 | ||||
-rw-r--r-- | view/tpl/notifications_widget.tpl | 4 |
2 files changed, 21 insertions, 12 deletions
diff --git a/view/js/main.js b/view/js/main.js index 8b8b5d918..658dd8b6f 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -209,20 +209,21 @@ $(document).ready(function() { updateInit(); - var e = document.getElementById('content-complete'); - if(e) + if (document.getElementById('content-complete')) { pageHasMoreContent = false; + } - $(document).on('hz:updateConvItems', function(event) { - if(!bParam_mid) + document.addEventListener('hz:updateConvItems', function(e) { + if (!bParam_mid) { cache_next_page(); + } }); - $(document).on('hz:handleNetworkNotificationsItems', function(e, obj) { + document.addEventListener('hz:handleNetworkNotificationsItems', function(e) { push_notification( - obj.name, - $('<p>' + obj.message + '</p>').text(), - obj.b64mid + e.detail.name, + $('<p>' + e.detail.message + '</p>').text(), + e.detail.b64mid ); }); }); @@ -684,6 +685,16 @@ function updateConvItems(mode, data) { existingElem.replaceWith(elem); } + // DOMParser will prevent scripts from execution for security reasons. + // We remove all scripts but possibly injected some from + // addons like for example gallery later. + // TODO: make the script run from the addon itself. + let scripts = elem.querySelectorAll('script'); + scripts.forEach(script => { + let scriptContent = script.textContent || script.innerText; + eval(scriptContent); // Execute the script + }); + // set the comment state to the state we discovered earlier if (isVisible) { showHideComments(itmId); @@ -736,8 +747,6 @@ function updateConvItems(mode, data) { if (followUpPageLoad) { document.dispatchEvent(new Event('hz:sse_bs_counts')); } else { - console.log('got here0'); - document.dispatchEvent(new Event('hz:sse_bs_init')); } diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl index 1ad054d37..cdef36eb3 100644 --- a/view/tpl/notifications_widget.tpl +++ b/view/tpl/notifications_widget.tpl @@ -487,7 +487,6 @@ } } - function sse_handleNotificationsItems(notifyType, data, replace, followup) { // Get the template, adjust based on the notification type @@ -544,7 +543,8 @@ } // Filter thread_top notifications if the filter is active - if (document.getElementById('tt-' + notifyType + '-only').classList.contains('active')) { + let filterThreadTop = document.getElementById('cn-' + notifyType + '-input'); + if (filterThreadTop && filterThreadTop.classList.contains('active')) { let notifications = notify_menu.querySelectorAll('[data-thread_top="false"]'); notifications.forEach(notification => notification.classList.add('tt-filter-active')); } |