Tampermonkey Script - getComputedStyle(variable).display inconsistency

21 Views Asked by At

I am trying to make a script that only triggers on certain conditions on a web tool.

There are two text blocks, when one is active, the style inspector says says: style="display: block" and the other is style="display: none"

When I use a command like the following though

console.log("Block status is: " + getComputedStyle(element1).display); Output is: block (as expected)

console.log("Block status is: " + getComputedStyle(element2).display); Output is: block (despite style inspector saying "none")

When printing the whole object using: console.log(getComputedStyle(element1).display); console.log(getComputedStyle(element2).display); Delving into them, they both say block, even though only one is displayed and the style inspector saying only one is displayed.

They are both a very simple class and I don't have much to work with when it comes to triggering an action based on their state. Can anyone help clarify what is happening here or recommend any alternative solutions?

0

There are 0 best solutions below