I am developing a Chrome extension and I want to load it after all page scripts have loaded.
Site page consists such code:
<html>
  <body>
  <div id="main">All body elements, texts, etc...</div>
  <script>
    window.netflix = window.netflix || {};
    netflix.falkorCache = {"genres":"58"}
  </script>
  </body>
</html>
My extension code is:
$(document).ready(function() {
  launchPlugin();
  function launchPlugin() {
    console.log(typeof(window.netflix));//I have also tried just `netflix`
    if(typeof(window.netflix)!=='undefined'){
      startNetflixPlayer();
    } else{
      setTimeout(
        function(){
          launchPlugin();
        }, 700);
    }
  }
  //other code...
});
But plugin never run startNetflixPlayer() because window.netflix is always undefined. I have also tried to check variable netflix but it also returns undefined.
At the same time if I try to check console.log(window.netflix) in Chrome's developer's console I see the result.
console.log(typeof(window.netflix)) returns object. But after this Chrome extension still doesn't see this variable and returns undefined.
I believe I miss something simple but can't understand what exactly.
Any ideas how to access the variable (and object data) from the website using extension's script?
P.S. I have checked this answer also but it's not working for me: chrome extension: run script after page has finished loading javascript
 
    