Replacing a javascript function inside an object using GreaseMonkey -


i having troubles finding way replace javascript function defined property of object. had googled 2 days , looked @ questions in stack overflow related overriding function javascript, none of solution worked. have webpage (http://gefs-online.com if helps), , there object called "multiplayer" declared somewhere that:

var multiplayer = window.multiplayer || {}; 

after that, there properties under multiplayer declared that:

multiplayer.nbusers = 0; multiplayer.users = {}; multiplayer.visibleusers = {}; multiplayer.minupdatedelay = 500; multiplayer.updatetimeout = null ; multiplayer.hearbeattimeout; multiplayer.hearbeatlife = 9000; multiplayer.userlife = 10000; multiplayer.userhalflife = 4000; multiplayer.mapupdateperiod = 10000; multiplayer.myid = ''; multiplayer.lastrequest = null ; multiplayer.lastrequesttime = 0; multiplayer.localtime = new date().gettime(); multiplayer.farvisibilityrange = 10000; multiplayer.lowvisibilityrange = 1000; multiplayer.nearvisibilityrange = 20; multiplayer.chatmessage = ''; multiplayer.chatmessageid = 0; multiplayer.on = false; multiplayer.started = false; multiplayer.callsignplacemarkaltitude = 4; multiplayer.updatefunctions = []; multiplayer.init = function() {}; 

the function i'm willing override multiplayer.loadmodel() declared that:

multiplayer.loadmodel = function(oplayer, odata, lod, callbackfunction) {     ... //the code of function }; 

now want override function using greasemonkey, without success. can't use regular method of unsafewindow - because not working, , if worked, firefox supports it.

i have read questions related subject, still didn't find anything, please don't rate down.

thanks whoever helps me.

update: tried again implementing unsafewindow that:

unsafewindow.multiplayer.loadmodel = function (oplayer, odata, lod, callbackfunction) {     console.log ("loadmodel()"); } 

but says : "referenceerror: unsafewindow not defined"

eventually, ==userscript== definition wrong. when using greasemonkey (firefox), should this:

// @grant        none 

but when using tampermonkey/violentmonkay (chrome/opera) should this:

// @grant        unsafewindow 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -