Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>About firing twice:</strong></p> <p>If the page contains <code>&lt;iframe&gt;</code>s, userscript will fire in each of them.</p> <p>You need to determine if you are inside <code>&lt;iframe&gt;</code> or not. The simplest way to fire only in main page, and not iframes, is to wrap all code with:</p> <pre class="lang-js prettyprint-override"><code>if(top==self) { ... } </code></pre> <p>To see if there are <code>&lt;iframe&gt;s</code> in the page (either hardcoded in HTML or dynamically generated) I always use AdBlock Plus ("Open blockable items" dialog).</p> <p>I'm not sure however why the second "inside" alert does not launch. I've created a simple HTML page containing <code>&lt;iframe&gt;</code> and I get two alerts fired.</p> <p><strong>About the script generally:</strong></p> <p>You're doing double work here. You don't have to wrap everything to execute the script. What Greasemonkey does is executing the code lines after page loads (on <code>DOMContentLoaded</code>). So you don't have to create <code>&lt;script&gt;</code> tag, set it's body and append to document. You can just write</p> <p><code>document.getElementById("postingHtmlToolbar").firstChild.innerHTML += ...</code></p> <p>and it should do what you want (you don't need <code>contentEval</code> function at all).</p> <p>I don't have any blog on blogger so I can't log and see any URL and the problematic behavior, but playing step by step with the code should be enough to debug.</p> <p><strong>Edit 2:</strong></p> <p>Seems that you should change <code>firstChild</code> to <code>firstElementChild</code>. </p> <ul> <li><a href="https://developer.mozilla.org/en/DOM/element.firstChild" rel="nofollow"><code>firstChild</code></a> returns <code>Node</code></li> <li><a href="https://developer.mozilla.org/En/DOM/Element.firstElementChild" rel="nofollow"><code>firstElementChild</code></a> returns <code>Element</code>.</li> </ul> <p>There is <code>innerHTML</code> property in <code>Element</code> (since Firefox 3.5), but not in <code>Node</code>. Yeah, it's really inconsistent and annoying at times. I've come into similar problem recently.</p> <p><strong>Edit 3:</strong></p> <p>There's a couple of things there. Please don't tell me it doesn't work still :)</p> <pre class="lang-js prettyprint-override"><code>var func = function() { var obj = document.getElementById("postingHtmlToolbar"); if(obj !== null){ // only if object exists, so we don't have errors //alert(obj); obj.style.display = 'block'; // it's hidden by default obj.firstElementChild.innerHTML += "FOO"; } } window.setTimeout(func, 3000); // execute with delay -- let's give Google's JS time to be loaded first </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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