Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome can't read style.display value
    text
    copied!<p>I have a weird problem. I try to write a GreaseMonkey script to be run in Firefox and Google Chrome. With Chrome I tried 2 extensions : "TamperMonkey" and "Blank Canvas Script Handler", mainly because my script check regulary for a new version on an external site and this is considered as cross site scripting and not authorized in Chrome.</p> <p>To show you my problem, I write a simple test case :</p> <pre><code>// ==UserScript== // @name test // @namespace http://fgs.ericc-dream.fr.nf // @description test gm script // @include http://gaia.fallengalaxy.eu/ // @author ericc // @version 0.0.1 // ==/UserScript== /* We attach an event listener to the body tag and trigger the function * 'message' each time that an element is inserted in the page */ var el = document.body; el.addEventListener('DOMNodeInserted', message, false); var extraFlag = false; function message(event) { /* first we capture the id of the new inserted element * (the one who created the event) */ var objId = event.target.id; /* add an event listener on the map container */ if (objId == "extra") { el = document.getElementById('extra'); el.addEventListener('DOMSubtreeModified',readTest,false); GM_log(el.style.display); } } function readTest() { el = document.getElementById('extra'); GM_log(extraFlag); GM_log(el.style.display); if ((el.style.display != 'none') &amp;&amp; (!extraFlag)) { alert('extra'); extraFlag = true; } else if ((el.style.display == 'none')) { extraFlag = false; } } </code></pre> <p>the div element 'extra' is modified by the page. The problem is that Chrome is unable to read the value of el.style.display and thus extraFlag never become 'false' again. I use this flag to avoid to run the code several time, the site is heavily JavaScript driven This code work nicely in Firefox ! </p> <p>I tried to search with Google but can't find a correct answers. Seems easy to change the value of display, but it seems that I'm the only one who try to read it !!!</p> <p>I write this code because "DOMAttrModified" isn't supported in Chrome :-( </p> <p>Thanks in advance for your help </p> <p>ericc</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload