/**
 * localize.js
 */

/* api */
const {i18n} = browser;

/* constants */
import {EXT_LOCALE} from "./constant.js";
const DATA_I18N = "data-i18n";

/**
 * localize attribute value
 * @param {Object} elm - element
 * @returns {void}
 */
export const localizeAttr = async elm => {
  if (elm && elm.nodeType === Node.ELEMENT_NODE &&
      elm.hasAttribute(DATA_I18N)) {
    const [id] = elm.getAttribute(DATA_I18N).split(/\s*,\s*/);
    if (id) {
      const attrs = {
        alt: "alt",
        ariaLabel: "aria-label",
        href: "href",
        placeholder: "placeholder",
        title: "title",
      };
      const items = Object.entries(attrs);
      for (const item of items) {
        const [key, value] = item;
        if (elm.hasAttribute(value)) {
          elm.setAttribute(value, i18n.getMessage(`${id}_${key}`));
        }
      }
    }
  }
};

/**
 * localize html
 * @returns {void}
 */
export const localizeHtml = async () => {
  const lang = i18n.getMessage(EXT_LOCALE);
  if (lang) {
    const nodes = document.querySelectorAll(`[${DATA_I18N}]`);
    if (nodes instanceof NodeList) {
      for (const node of nodes) {
        const [id, ph] = node.getAttribute(DATA_I18N).split(/\s*,\s*/);
        const data = i18n.getMessage(id, ph);
        if (data) {
          node.textContent = data;
        }
        if (node.hasAttributes()) {
          localizeAttr(node);
        }
      }
    }
    document.documentElement.setAttribute("lang", EXT_LOCALE);
  }
};

@@ -1066,47 +1066,8 @@
 %60);%0A
-    if (nodes instanceof NodeList) %7B%0A  
     
@@ -1096,26 +1096,24 @@
 es) %7B%0A      
-  
 const %5Bid, p
@@ -1166,26 +1166,24 @@
 s*/);%0A      
-  
 const data =
@@ -1210,26 +1210,24 @@
  ph);%0A      
-  
 if (data) %7B%0A
@@ -1234,18 +1234,16 @@
         
- 
- 
 node.tex
@@ -1269,52 +1269,10 @@
     
-  
 %7D%0A
-        if (node.hasAttributes()) %7B%0A    
     
@@ -1293,34 +1293,16 @@
 (node);%0A
-        %7D%0A      %7D%0A
     %7D%0A  
@@ -1349,26 +1349,20 @@
 %22lang%22, 
-EXT_LOCALE
+lang
 );%0A  %7D%0A%7D

Update src/mjs/localize.js