- open any overwolf window
- add stringify version that includes functions
function JSONstringifyWithFuncs(obj) {
Object.prototype.toJSON = function() {
var sobj = {}, i;
for (i in this)
if (this.hasOwnProperty(i))
sobj[i] = typeof this[i] == 'function' ?
this[i].toString() : this[i];
return sobj;
};
Array.prototype.toJSON = function() {
var sarr = [], i;
for (i = 0 ; i < this.length; i++)
sarr.push(typeof this[i] == 'function' ? this[i].toString() : this[i]);
return sarr;
};
var str = JSON.stringify(obj);
delete Object.prototype.toJSON;
delete Array.prototype.toJSON;
return str;
}
- run with overwolf object
JSONstringifyWithFuncs(overwolf)
- copy output to JSON file (removing leading and trailing quote)
- run regExp replace
/"function.*["|$]/g
, replacing with your favorite spy/stub/mock base function ( e.g.sinon.stub() ) - adapt as needed
TODO: create configurable script that does this and enables to configure specific mock implementations for updating