user2061745
user2061745

Reputation: 305

how to edit a js object/function

Hi i am using an api but i should make a patch for it

Songapi.prototype.goPlaySong=Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false');

doesn't work also tried

Songapi.prototype.goPlaySong=Function(Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false'));

or

Songapi.prototype.goPlaySong=eval(Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false'));

still couldn't do it any idea?

Upvotes: 0

Views: 87

Answers (3)

user2061745
user2061745

Reputation: 305

var newgoPlaySong=Songapi.prototype.goPlaySong.toString().replace('$.inArray(response.provider,["universal","emi","warner"]) !== -1','false');
eval('Songapi.prototype.goPlaySong = '+gecicigoPlaySong+';');

it worked thanks

Upvotes: 0

flavian
flavian

Reputation: 28511

DEMO

SongApi is a constructor a.k.a a class.

function inherits(child, parent) {
  function temp() {};
  temp.prototype = parent.prototype;
  child.prototype = new temp();
  child.prototype.constructor = child;
};

var CustomizedApi = function() {
    SongApi.call(this);
};
inherits(CustomizedApi, Songapi);
// or use Object.create for inheritance.
CustomizedApi.prototype = Object.create(SongApi.prototype);

/**
 * @override
 */
CustomizedApi.prototype.goPlaySong = function() {
   // override with whatever you want.
};
var api = new CustomizedApi;
api.goPlaySong();

Upvotes: 3

Virus721
Virus721

Reputation: 8345

Try :

eval('var code = ' + Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false'));

Songapi.prototype.goPlaySong = code;

But this is absolute dirtiness.

Upvotes: 1

Related Questions