-
-
Save xerxesb/1744913 to your computer and use it in GitHub Desktop.
var BetterNetbank = { | |
inject: function(table) { | |
if ($("#" + table).length > 0) { | |
$('#' + table + ' thead tr').prepend('<th>X</th>'); | |
$('#' + table + 'Body > tr').map(function() { | |
$(this).prepend('<td><input type="checkbox" /></td>'); | |
}); | |
} | |
} | |
} | |
BetterNetbank.inject('transactionsTable'); | |
BetterNetbank.inject('outstandingAuthorizationsTable'); | |
var theShizzle = function() { | |
BetterNetbank.inject('transactionsTable'); | |
BetterNetbank.inject('outstandingAuthorizationsTable'); | |
} | |
var doTheShizzle = function(event) { | |
document.removeEventListener('DOMSubtreeModified', doTheSizzle,true); | |
if (event.target.id == "ctl00_BodyPlaceHolder_updatePanelResults" && event.target.innerHtml != "") | |
theShizzle(); | |
document.addEventListener('DOMSubtreeModified', doTheSizzle,true); | |
return true; | |
} | |
document.addEventListener('DOMSubtreeModified', doTheSizzle,true); | |
//$('#ctl00_BodyPlaceHolder_btnSearch_field').bind('click', theShizzle); | |
//$('#ctl00_BodyPlaceHolder_divDetails').bind('DOMAttrModified', theShizzle); | |
//$('#ctl00_BodyPlaceHolder_updatePanelResults').bind('DOMSubtreeModified', theShizzle); | |
$(document).bind('DOMSubtreeModified', theShizzle); | |
var c = $('#ctl00_BodyPlaceHolder_divDetails'); | |
c.__setAttribute = c.setAttribute; | |
c.setAttribute = function(){ | |
alert('new item added'); | |
c.__setAttribute.apply(c, arguments); |
without line 18 I get
Uncaught ReferenceError: transactions is not defined
I'll update the window.bnb stuff once i can see that the transactions var is being accessed properly...atm that block isnt even being called
They're related issues of scope. I wonder if it's related to the way jQuery is attaching the binding. Declare the function non-anonymously above the event binding and pass the function through as an argument? That way you can call the function yourself in a console without using the binding.
updated JS (see above). same problem though - here line 17 "transactions" is undefined
Line 16 is superfluous but not harmful. Remove the event
function parameter and then try calling theShizzle();
in a console window. Same error?
If the page is just sitting idle, "theShizzle" in the console yields ReferenceError: theShizzle is not defined
If i break into the callback and access theShizzle, it finds the object perfectly well...
Just going to record here that the issue was the Chrome Extension sandbox.
stupid sandbox
You don't need any of the
window.bnb
stuff (yourBetterNetbank
variable has the same scope). You should be able to change lines 24 and 25 to justBetterNetbank.inject(...
.What happens if you comment out line 18?