0
<div id="div-id1" style="height:250px; width:300px;">
    <div id="child_divId1" style="border: 0pt none;">
        <iframe id="iframe_from_div" title="some tests" name="iframe_fromdiv" width="300" height="250" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" srcdoc="" style="border: 0px; vertical-align: bottom;" data-load-complete="true">
        </iframe>
    </div>
</div>

<script type="text/javascript">
    var initializedVar = document.getElementById("div-id1");
</script>

Here is a simplified version of the situation, but main idea is to use an chrome extension where I use queryselectorall to obtain a nodelist of my divs I want. After that I clone the node and I append it to parentNode with div id +"genuine" syntax. All of that because I need to filter the mutation of those divs.
I cannot use observer.observ because that assume to see the mutation after has been made, so I need to use proxy instead. The problem is that the scripts from the webpages will continuously modify the divs and I need to filter that replacing the initialized variable used by scripts with my proxied one.

So, can I check if a variable has been initialized for a specific div id ?

Thanks.

sniper
  • 1
  • 2
  • You mean like `initializedVar.id === 'div-id1'`? – Justinas Oct 08 '20 at 11:25
  • Given that it's entirely possible to hide a variable from other code, the answer is "no". – Ouroborus Oct 08 '20 at 11:29
  • Welcome to Stack Overflow! Please take the [tour] (you get a badge!), have a look around, and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask). I'm afraid it's unclear what you're trying to do and what problem you're having doing it. If you're trying to **prevent** DOM mutations on the page, you probably can't. You've mentioned Proxy -- you can't put a Proxy for a DOM element in the DOM (at least not on Chrome). It's not clear have variables come into this at all. – T.J. Crowder Oct 08 '20 at 11:29
  • 1
    @T.J.Crowder "If you're trying to prevent DOM mutations". this is exactly what I want and i was 90% is not possible but it's always worth a try. – sniper Oct 08 '20 at 23:21
  • @Justinas yes, only that I not know the name of initializedVar, is it initialized by a big obfuscated script. So I want to know which variable is === with 'div-id1'. – sniper Oct 08 '20 at 23:22
  • @Ouroborus thanks for answer, I was thought that is the answer from the beginning but worth a try. – sniper Oct 08 '20 at 23:24

0 Answers0