Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You say, when you run the original <code>.click()</code> code from Firebug it works.</p> <p>As iMoses pointed out, it doesn't work from a Greasemonkey script because the script fires before the page's javascript creates the targeted nodes.</p> <p>You also report that the <code>.on()</code> code does not work from either the script or Firebug. That means that the <code>onclick</code> function of your target nodes ( <code>ticketEditTableView()</code> ) is stopping event bubbling. It probably calls <code>event.stopPropagation()</code>.</p> <p>The solution is to go back to <code>.click()</code> but apply it as the target nodes are added to the page. This can be done with <a href="https://gist.github.com/2625891" rel="nofollow">the waitForKeyElements() utility</a>.</p> <p>Here is <strong>a complete script</strong> that uses <code>waitForKeyElements</code> to bind <code>.click()</code> to those nodes as they are added to the page:</p> <pre><code>// ==UserScript // @name Desk Notifications // @description Displays special notifications to NVOWS coaches at desk.com // @downloadURL http://www.example.com/deskNotifications.user.js // @include http://nvows.desk.com/agent // @namespace http://www.example.com/userscripts // @updateURL http://www.example.com/deskNotifications.meta.js // @version 0.1 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @grant GM_addStyle // ==/UserScript== /*- The @grant GM_addStyle directive is needed to work around a design change introduced in GM 1.0. It restores the sandbox. */ waitForKeyElements ( ".interaction_type_60, .interaction_type_40", addAlertOnClick ); function addAlertOnClick (jNode) { jNode.click (alertOnClick); } function alertOnClick (zEvent) { var targNode = $(zEvent.currentTarget); var messageStr = "Oopsie!"; if (targNode.hasClass ("interaction_type_60") ) { messageStr = "You clicked a type 60 case!" } else if (targNode.hasClass ("interaction_type_40") ) { messageStr = "You clicked a type 40 case!" } alert (messageStr); } </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