0

嗨,我正在使用一个 api,但我应该为它打一个补丁

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

没用也试过

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

或者

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

还是想不通?

4

3 回答 3

3

演示

SongApiconstructor又名一类。

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();
于 2013-07-15T15:33:22.633 回答
1

尝试 :

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

Songapi.prototype.goPlaySong = code;

但这绝对是肮脏的。

于 2013-07-15T15:32:06.687 回答
0
var newgoPlaySong=Songapi.prototype.goPlaySong.toString().replace('$.inArray(response.provider,["universal","emi","warner"]) !== -1','false');
eval('Songapi.prototype.goPlaySong = '+gecicigoPlaySong+';');

它起作用了,谢谢

于 2013-07-15T15:36:45.623 回答