diff --git a/app/customCSS/index.js b/app/customCSS/index.js index 044df27c..83a738e1 100644 --- a/app/customCSS/index.js +++ b/app/customCSS/index.js @@ -2,23 +2,60 @@ const fs = require('fs'); const path = require('path'); exports.onDidFinishLoad = function onDidFinishLoad(content, config) { - applyCustomCSSStyleIfPresent(content, config); + const customCssLocation = getCustomCssLocation(config); + if (customCssLocation) { + applyCustomCSSToContent(content, customCssLocation) + } content.insertCSS('#download-mobile-app-button, #download-app-button, #get-app-button { display:none; }'); content.insertCSS('.zoetrope { animation-iteration-count: 1 !important; }'); }; -function applyCustomCSSStyleIfPresent(content, config) { +exports.onDidFrameFinishLoad = function onDidFrameFinishLoad(webFrame, config) { + const customCssLocation = getCustomCssLocation(config); + if (customCssLocation) { + applyCustomCSSToFrame(webFrame, customCssLocation); + } +} + +function getCustomCssLocation(config) { if (config.customCSSName) { - applyCustomCSSFromLocation(content, path.join(__dirname, 'assets', 'css', config.customCSSName + '.css')); + return path.join(__dirname, "assets", "css", config.customCSSName + ".css"); } else if (config.customCSSLocation) { - applyCustomCSSFromLocation(content, config.customCSSLocation); + return config.customCSSLocation; } + return null; } -function applyCustomCSSFromLocation(content, cssLocation) { +function applyCustomCSSToContent(content, cssLocation) { fs.readFile(cssLocation, 'utf-8', (error, data) => { if (!error) { content.insertCSS(data); } }); } + +// Teams V2 use iframe for the main view. The content.insertCSS +// does not work for that for some reason, so here, we listen for +// on-did-frame-finish-load events, and inject additional