Exemplo n.º 1
0
 return Promise.resolve().then(() => {
     const text = kdbxweb.ByteUtils.bytesToString(data);
     const localeData = JSON.parse(text);
     SettingsManager.allLocales[locale.name] = locale.title;
     SettingsManager.customLocales[locale.name] = localeData;
     this.logger.debug('Plugin locale installed');
 });
Exemplo n.º 2
0
 return Promise.resolve().then(() => {
     const text = kdbxweb.ByteUtils.bytesToString(data);
     const id = 'plugin-css-' + name;
     this.createElementInHead('style', id, 'text/css', text);
     if (theme) {
         const locKey = this.getThemeLocaleKey(theme.name);
         SettingsManager.allThemes[theme.name] = locKey;
         BaseLocale[locKey] = theme.title;
         for (const styleSheet of document.styleSheets) {
             if (styleSheet.ownerNode.id === id) {
                 this.processThemeStyleSheet(styleSheet, theme);
                 break;
             }
         }
     }
     this.logger.debug('Plugin style installed');
 });
Exemplo n.º 3
0
 return Promise.resolve().then(() => {
     let text = kdbxweb.ByteUtils.bytesToString(data);
     this.module = {exports: {}};
     const id = 'plugin-' + Date.now().toString() + Math.random().toString();
     global[id] = {
         require: PluginApi.require,
         module: this.module
     };
     text = `(function(require, module){${text}})(window["${id}"].require,window["${id}"].module);`;
     const ts = this.logger.ts();
     this.createElementInHead('script', 'plugin-js-' + name, 'text/javascript', text);
     return new Promise((resolve, reject) => {
         setTimeout(() => {
             delete global[id];
             if (this.module.exports.uninstall) {
                 this.logger.debug('Plugin script installed', this.logger.ts(ts));
                 this.loadPluginSettings();
                 resolve();
             } else {
                 reject('Plugin script installation failed');
             }
         }, 0);
     });
 });