From dced9324e2a5f3dd25ede5de0f95e77811ea7b9d Mon Sep 17 00:00:00 2001 From: TheGoddessInari Date: Wed, 1 Aug 2018 06:57:57 -0700 Subject: [PATCH] Replace shipped js_unread with user js_unread if supplied. Also go back to isolation between js_unread and custom_js as a result. This counts as a FLAG DAY. js_unread NOT being used for badge updates needs to be moved to custom_js. If you don't want the host website to be able to access your functions and variables, use block-scoped declarations such as 'let' and 'const' instead of 'var'. --- app/ux/WebView.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/ux/WebView.js b/app/ux/WebView.js index c0c61e43..0ef54f4a 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -417,21 +417,18 @@ Ext.define('Rambox.ux.WebView',{ var js_inject = ''; var css_inject = ''; - let js_injected = false; // Injected code to detect new messages if ( me.record ) { - let js_unread = Ext.getStore('ServicesList').getById(me.record.get('type')).get('js_unread'); - js_unread += me.record.get('js_unread'); + let js_unread = me.record.get('js_unread'); + if (!js_unread) { + js_unread += Ext.getStore('ServicesList').getById(me.record.get('type')).get('js_unread'); + } if ( js_unread !== '' ) { console.groupCollapsed(me.record.get('type').toUpperCase() + ' - JS Injected to Detect New Messages'); console.info(me.type); console.log(js_unread); console.groupEnd(); - if (!js_injected) { - js_injected=true; - js_inject += '{'; - } - js_inject += js_unread; + js_inject += '{' + js_unread + '}'; } let custom_js = Ext.getStore('ServicesList').getById(me.record.get('type')).get('custom_js'); custom_js += me.record.get('custom_js'); @@ -440,11 +437,7 @@ Ext.define('Rambox.ux.WebView',{ console.info(me.type); console.log(custom_js); console.groupEnd(); - if (!js_injected) { - js_injected=true; - js_inject += '{'; - } - js_inject += custom_js; + js_inject += '{' + custom_js + '}'; } const custom_css_complex = me.record.get('custom_css_complex'); if (custom_css_complex === false) { @@ -458,7 +451,6 @@ Ext.define('Rambox.ux.WebView',{ css_inject += custom_css; } } - if (js_injected) js_inject += '}'; } // Prevent Title blinking (some services have) and only allow when the title have an unread regex match: "(3) Title"