Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, a general debugging tip, then a stab at your problem.</p> <p>Remember that Greasemonkey scripts are just javascript, and you can still use all the Javascript tools avaiable to you to debug your problem. Open up gmail, fire up <a href="http://www.getfirebug.com" rel="nofollow noreferrer">Firebug</a>, and try running your javascript code directly on the command line (click the upward circle arrow to the right of the console line for a bigger typing area).</p> <p>When I did the above with your javascript snippet, allLinks.snapshotLength was evaluating to 0, indicating that your xpath expression didn't match anything. This is odd, because when I used <a href="https://addons.mozilla.org/en-US/firefox/addon/1095" rel="nofollow noreferrer">XPath Checker</a>, it matched the logo. </p> <p>Digging in a bit deeper, it looks like gmail's main document is a number of iframes, and the iframes contain the actual application elements. Specifically, there's a frame with an ID of "canvas_frame" which contains the actual DOM for the application interface. When I try </p> <pre><code>canvas = window.frames[document.getElementById('canvas_frame').name].document; allLinks = canvas.evaluate( "//html/body/div[1]/div/div/div[1]/div/div[3]/div[1]/div[2]/div[2]/div[1]/div[1]", canvas, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); </code></pre> <p>I get a response with a length of 1, which may suit your needs better.</p> <p>Finally, this isn't required, but your xPath expression looks a little fragile. If gmail changes the document structure even slightly (say, with a wrapper div), your program will break. Consider something like this instead.</p> <pre><code>&lt;!-- all divs on the page that contains an h1 element that contains the text "Gmail Logo" --&gt; //div[contains(./h1,"Gmail Logo")] </code></pre>
 

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