index.js
/**
   * Set the text contents of the matched elements.
   * @param {string} selector CSS selector.
   * @param {string} value The text to set as the content of each matched element.
   * @returns {Promise}
   */
Set the text contents of the matched elements.
@param {string} selector CSS selector.
@param {string} value The text to set as the content of each matched element.
@returns {Promise}
Set the text contents of the matched elements . @param { string } selector CSS selector . @param { string } value The text to set as the content of each matched element . @returns { Promise }
text(selector, value) {
    const _s = Webview.replaceWrongQuotes(selector);
    if (typeof value === 'undefined') {
      return this.runJs(`
        let _getText = el => {
            if (!el) return '';
            if ([Node.ELEMENT_NODE, Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE].includes(el.nodeType)) {
              if (typeof el.textContent === 'string') {
                return el.textContent;
              }
              let result = [];
              for (el = el.firstChild; el; el = el.nextSibling) {
                result.push(_getText(el));
              }
              return result.join('');
            }
            if ([Node.TEXT_NODE, Node.CDATA_SECTION_NODE].includes(el.nodeType)) {
              return el.nodeValue;
            }
            if (!el.nodeType) {
              let node;
              let i = 0;
              let result =[];
              while (node = el[i++]) {
                result.push(_getText(node));
              }
              return result.join('');
            }
        };
        return _getText(document.querySelectorAll('${_s}'));
      `);
    }
    return this.runJs(`
      document.querySelectorAll('${_s}')
        .forEach(el => el.textContent = '${value}');
    `);
  }
text ( selector , value ) { const _s = Webview . replaceWrongQuotes ( selector ) ; if ( typeof value === 'undefined' ) { return this . runJs ( ` ${ _s } ` ) ; } return this . runJs ( ` ${ _s } ${ value } ` ) ; }
Set the text contents of the matched elements.
Set the text contents of the matched elements .