Trying to select a dom item on a page built by React with JS console

Viewed 20

Using the script with Tampermonkey (a user script manager), I am trying to select an HTML element after the page has been rendered. This is a live site that is not my own.

I inspected the source code and can see there is a "React developer tools" folder and a "webpack" folder.

It seems I am only able to select the elements I want when I select said HTML elements with the dev tools and then target it with javascript. I need a way to do this solely through script.

Here is the code I am using.

(function() {
    'use strict';
    // Your code here...
if (location.href === "https://annotate.appen.com/")
{
    function jobFunction() {
      let anchorSearch = () => {
        let theLink = document.querySelector("td > a");
        if (!theLink) {
          console.log("second check")
          location.reload(true);
        }
        else {
          return
        }
      };
      console.log("first check")

      function checkDom (){
        let tableDom =document.querySelector('td');
          if (tableDom) {
            console.log("Dom Loaded, starting check")
          anchorSearch()
          }
          else {
            console.log('checking dom..')
            setInterval(checkDom, 5000)
        }
      }
      checkDom()
    }
    jobFunction();

  }
})();
0 Answers
Related