Cruyer VS
Cruyer VS

Reputation: 1

Getting all <a> Tags even after changes on the page

In the Mailstore Webclient there sadly aren't a lot of features.

All the folders are <a> Tags with the name scheme "archives-tree-view-0-expand-link". "Mein Archive" = archives-tree-view-0-expand-link "Exchange kevin.krippner" = archives-tree-view-0-0-expand-link

So what I have been trying is to inject a script that gets all the <a> tags and looks if the id of that tag includes -expand-link. If that is the case than I do .click() on that ElementByID to open it.

It works for the first instance of "Mein Archiv" but after that I somehow need to get all <a> tags again after "Mein Archive" has opened since they aren't all shown/selectable from the start (subtree is hidden.)

const tags = document.querySelectorAll("a")
    console.log("Current Amount of <a> Tags: " + tags.length)
    var icounter=0
    var opened = new Array;
    while(icounter<document.querySelectorAll("a").length){
         tags.forEach(a=>{console.log("Testrun:");if(a.getAttribute("id").includes("-expand-link")==true){
            if(opened.length==0 || opened.includes('""')||opened.includes(a.getAttribute("id"))== false){
                console.log(a.getAttribute("id")+" has been clicked.");
                document.getElementById(a.getAttribute("id")).click();
                opened.unshift(a.getAttribute("id"));
            }}else{console.log("No <a> Expand Tag clicked")}})
        console.log("New Amount of <a> Tags: " + tags.length)
        icounter++
        console.log("New Amount of <a> Tags:" + (document.querySelectorAll("a")))
        if(tags.length<document.querySelectorAll("a").length){
            console.log("Tags Reset: " + tags)
            tags=document.querySelectorAll("a")
            icounter=0
            lo=0
        }
    }

Simply checking if there is more <a> tags with another querySelectorAll doesn't seem to work.

Structure

Upvotes: 0

Views: 76

Answers (0)

Related Questions