You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

checkChromeExtensionsInstalled.web.ts 874B

1234567891011121314151617181920212223242526
  1. /**
  2. * Checks whether the chrome extensions defined in the config file are installed or not.
  3. *
  4. * @param {Object} config - Objects containing info about the configured extensions.
  5. *
  6. * @returns {Promise[]}
  7. */
  8. export default function checkChromeExtensionsInstalled(config: any = {}) {
  9. const isExtensionInstalled = (info: any) => new Promise(resolve => {
  10. const img = new Image();
  11. img.src = `chrome-extension://${info.id}/${info.path}`;
  12. img.setAttribute('aria-hidden', 'true');
  13. img.onload = function() {
  14. resolve(true);
  15. };
  16. img.onerror = function() {
  17. resolve(false);
  18. };
  19. });
  20. const extensionInstalledFunction = (info: any) => isExtensionInstalled(info);
  21. return Promise.all(
  22. (config.chromeExtensionsInfo || []).map((info: any) => extensionInstalledFunction(info))
  23. );
  24. }