I am attempting to write my first userscript using Greasemonkey, in Firefox. I have done a good bit of research because I am new to userscripts and jQuery but I can't seem to get this simple test script to work. So far I have this in the Test.user.js
file:
// ==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
// @grant none
// ==/UserScript
$(document).ready(function(){
alert('Script loaded.');
$('.interaction_type_60').click(function() {
alert("You clicked a case!");
});
$('.interaction_type_40').click(function() {
alert("You clicked a case!");
});
});
What I need it to do is obviously a lot more complicated but because I am new to jQuery and userscripts I just wanted to make this work first. So far the "Script Loaded." is being displayed so that rules out a lot of possible problems. When I run only this part of the code in firebug it works fine:
$(document).ready(function(){
alert('Script loaded.');
$('.interaction_type_60').click(function() {
alert("You clicked a case!");
});
$('.interaction_type_40').click(function() {
alert("You clicked a case!");
});
});
So that rules out having code errors or grabbing a wrong class selector. I can't see what could be the issue if the code is right and it is being executed. If anyone could help that would be greatly appreciated. I am not a newbie to programming. Just web based stuff.
Here is the part of the HTML page that I am trying to see when it is clicked.
<tbody id="ticket_filter_list_items" class=" ">
<tr id="ticket_filter_item_73354627" class="ticket_filter_item ticket_filter_item_table_view interaction_type_60 ticket_filter_item_open ticket_filter_item_current_selected" onclick=" ticketEditTableView(73354627, event);return false; " data-in-search="" data-ticket-id="73354627" style="">
<tr id="ticket_filter_item_73382205" class="ticket_filter_item ticket_filter_item_table_view interaction_type_40 ticket_filter_item_open " onclick=" ticketEditTableView(73382205, event);return false; " data-in-search="" data-ticket-id="73382205" style="">
</tbody>
This is off topic and not a big deal but if you see something that would make this userscript execute on pages that aren't 'http://nvows.desk.com/agent' then let me know. It says "Script loaded." every time I go to Stack Overflow. Ha.
--------------------------------------
UPDATE: I just tried to do this for testing:
$(document)
.on('click', this, function(){
alert('Please Work!!!!');
})
The things that I have been trying to click this whole time are the things that are not displaying the message. All of them are loaded with javascript after the page is loaded. I am almost positive that is the reason they will not allow me to click them. Is there a way to click these items. In the HTML script they look the same as the other elements.