historystamp historystamp - 1 year ago 110
Javascript Question

Modify javascript that was downloaded as part of a web page

I would like to modify the Javascript that is downloaded as part of a web page.

I have this page:

I would like to modify the function jspaginate.init. I've gotten this far:

Object { data: Object, loading: false, init: jspaginate.init(), update: jspaginate.update(), pushState: jspaginate.pushState(), loadingSequence: jspaginate.loadingSequence(), removeLoading: jspaginate.removeLoading(), updateUI: jspaginate.updateUI(), getData: jspaginate.getData() }

function jspaginate.init()
function (action, last){
var view = this,
target, current;
... clipped ...

This page includes lots of javascript. The function jspaginate is download from the site server. Nevertheless, I need to change the function jspaginate. I do not have access to the server. I want to change my copy of jspaginate. I know that I need to change the function every time it is downloaded.

I'm using GreaseMonkey to insert some javascript.

Answer Source

Just override the init function with its new definition, like below:

window.jspaginate.init = function() { 
   console.log('there you go');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download