const locale = (Array.from(document.body.classList).find(cls => cls.match(/^Locale_/)));

/**
 * Update CV tags
 * @param localeData
 */
const show_facebook_cv_tags = function(localeData) {
  const images = [...document.getElementsByTagName('img')];
  const localeRegex = new RegExp(localeData.separator_regex, 'i');

  images.forEach(function(el) {
    if (el.hasAttribute("data-prev-alt") &&
      el.getAttribute("data-prev-alt") === el.getAttribute("alt")) {
      return;
    }

    el.setAttribute("data-prev-alt", el.alt);

    const altText = el.alt;
    const isCVTag = altText.startsWith(localeData.tag_prefix);

    if (isCVTag) {
      const tags = altText.slice(localeData.tag_prefix.length).split(localeRegex);
      let html = "<ul style='position:absolute;top:10px;right:10px;padding:5px;font-size:12px;line-height:1.8;background-color:rgba(0,0,0,0.7);color:#fff;border-radius:5px'>";

      tags.forEach(function(tag) {
        let prefix = "∙";

        if (tag in localeData.emoji_map) {
          prefix = localeData.emoji_map[tag];
        } else if (tag.endsWith(localeData.tag_ends_with)) {
          prefix = localeData.emoji_map[localeData.tag_ends_with_map];
        }

        html += `<li>${prefix} ${tag}</li>`;
      });

      html += "</ul>";

      el.style.position = 'relative';
      el.insertAdjacentHTML('afterend', html);
    }
  });
};

/**
 * Initialize the plugin
 * @param localeData
 */
const initializePlugin = function(localeData) {
  const observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
      show_facebook_cv_tags(localeData);
    });
  });

  const config = {
    attributes: true,
    childList: true,
    characterData: false
  };
  observer.observe(document.body, config);

  show_facebook_cv_tags(localeData);
};


/**
 * Make the fetch request to get locale data
 * @param localePath
 */
const makeLocaleRequest = function(localePath) {
  fetch(chrome.extension.getURL(localePath))
    .then(response => response.json())
    .then(data => initializePlugin(data))
    .catch(function(err) {
      console.error('FB COMPUTER VISION TAGS ERROR', err);
    });
};

/**
 * Check for locale
 */
if (locale === 'Locale_es_LA') {
  makeLocaleRequest('/locales/es/messages.json');
} else if (locale === 'Locale_de_DE') {
  makeLocaleRequest('/locales/de/messages.json');
} else if (locale === 'Locale_en_GB' || locale === 'Locale_en_US') {
  makeLocaleRequest('/locales/en_US/messages.json');
} else if (locale === 'Locale_fr_FR') {
  makeLocaleRequest('/locales/fr/messages.json');
} else if (locale === 'Locale_it_IT') {
  makeLocaleRequest('/locales/it_IT/messages.json');
} else if (locale === 'Locale_vi_VN') {
  makeLocaleRequest('/locales/vi_VN/messages.json');
}

@@ -359,33 +359,33 @@
 el.hasAttribute(
-%22
+'
 data-prev-alt%22) 
@@ -381,17 +381,17 @@
 prev-alt
-%22
+'
 ) &&%0A   
@@ -401,33 +401,33 @@
 el.getAttribute(
-%22
+'
 data-prev-alt%22) 
@@ -423,17 +423,17 @@
 prev-alt
-%22
+'
 ) === el
@@ -450,13 +450,13 @@
 ute(
-%22alt%22
+'alt'
 )) %7B
@@ -497,17 +497,17 @@
 tribute(
-%22
+'
 data-pre
@@ -511,17 +511,17 @@
 prev-alt
-%22
+'
 , el.alt
@@ -735,17 +735,17 @@
  html = 
-%22
+'
 %3Cul styl
@@ -746,17 +746,17 @@
 l style=
-'
+%22
 position
@@ -893,11 +893,11 @@
 :5px
-'%3E%22
+%22%3E'
 ;%0A%0A 
@@ -955,11 +955,11 @@
 x = 
-%22%E2%88%99%22
+'%E2%88%99'
 ;%0A%0A 
@@ -1263,15 +1263,15 @@
  += 
-%22
+'
 %3C/ul%3E
-%22
+'
 ;%0A%0A 

Update single quotes to double quotes