title: Get Text From DOM object. Chrome Extension
body: <p>I have page <a href="https://somepage" rel="nofollow noreferrer">https://somepage</a> in internet. Here is part of it's code from chrome code: </p>
  
  <pre><code>..............
  &lt;div class="wr"&gt;
  &lt;div class="auth_username"&gt;tesеDom@mail.com&lt;/div&gt;
  &lt;div class="auth_stars"&gt;
  &lt;i class="fa fa-star-o fa-fw"&gt;
  ...........................
  </code></pre>
  
  <p>I have seen many answers and examples, but my code still not working. Seems I am missing something. My manifest:</p>
  
  <pre><code>{
      "manifest_version": 2,
  
      "name": "Bot_copy",
      "version": "1.0",
    "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
      "icons": {
  "48": "48x48.png",
  "128": "128x128.png"
      },
      "content_scripts": [{
      "matches": [ "https://mypage.my" ],
      "js": ["helloWorld.js"]
  
  
      }],
  
      "permissions": [
      "activeTab",
      "alarms",
      "clipboardRead",
      "clipboardWrite",
      "bookmarks",
      "contextMenus",
      "contentSettings",
      "downloads",
      "history",
      "nativeMessaging",
      "browsingData",
      "proxy",
      "webRequest",
      "webRequestBlocking",
      "cookies",
      "tabs",
      "webNavigation",
      "storage",
      "tabCapture",
      "notifications",
      "http://*/",
      "https://*/",
      "&lt;all_urls&gt;",
      "unlimitedStorage",
      "debugger"
      ],
  
      "browser_action": {
  "default_title": "Open"
    },
      "background": {
  "scripts": ["background.js"]    
    }
  }
  </code></pre>
  
  <p>content script</p>
  
  <pre><code>    window.onload = function() {
      sendMessage();
      }
  
      chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
  
      sendResponse({
  response: "Message received"
        });
      });
  
      //Send message to background page
      function sendMessage() {
  //Construct &amp; send message
  chrome.runtime.sendMessage({
  
              whattodo:"get_authname"
  }, function(response) {
  
  });
      }
  </code></pre>
  
  <p>background</p>
  
  <pre><code>chrome.runtime.onMessage.addListener(
      function(request, sender, sendResponse) {
  
      var name = document.getElementsByClassName('auth_username').value;
      alert(name);
  sendResponse({
      response: "Message received"
  });
      }
  );
  </code></pre>
  
  <p>I received alert "undefined".</p>
  
  <p>Have no idea. Really strange there are no properly documentation I don't understand object document.</p>
  
  <p>Seems I miss how to use documentc object. I tried also document.getElementsByTagName('auth_username'), but it also not working. Which way is correct?</p>