Skip to content

Instantly share code, notes, and snippets.

@xerxesb
Created February 5, 2012 11:39
Show Gist options
  • Save xerxesb/1744913 to your computer and use it in GitHub Desktop.
Save xerxesb/1744913 to your computer and use it in GitHub Desktop.
Netbank hackery
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);
@kitgrose
Copy link

kitgrose commented Feb 5, 2012

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.

@xerxesb
Copy link
Author

xerxesb commented Feb 5, 2012

updated JS (see above). same problem though - here line 17 "transactions" is undefined

@kitgrose
Copy link

kitgrose commented Feb 5, 2012

Line 16 is superfluous but not harmful. Remove the event function parameter and then try calling theShizzle(); in a console window. Same error?

@xerxesb
Copy link
Author

xerxesb commented Feb 5, 2012

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...

@kitgrose
Copy link

Just going to record here that the issue was the Chrome Extension sandbox.

@xerxesb
Copy link
Author

xerxesb commented Feb 13, 2012

stupid sandbox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment