Firefox插件:如何覆盖UI功能?
实际上,我想修改拼写检查器的replaceWord功能 我尝试了(在我自己的firefox扩展中)onInit:Firefox插件:如何覆盖UI功能?,firefox,firefox-addon,Firefox,Firefox Addon,实际上,我想修改拼写检查器的replaceWord功能 我尝试了(在我自己的firefox扩展中)onInit: original_replaceWord = InlineSpellCheckerUI.replaceWord; InlineSpellCheckerUI.replaceWord = function() { // things i would like to do (i.e. set the Cursor to another spot in the editor)
original_replaceWord = InlineSpellCheckerUI.replaceWord;
InlineSpellCheckerUI.replaceWord = function()
{
// things i would like to do (i.e. set the Cursor to another spot in the editor)
// call of the original function
return original_replaceWord.apply(this, arguments);
};
但这似乎不起作用,因为在我替换拼写错误的单词时没有调用此函数
如何找到正确的函数?我需要覆盖哪一个?
thx如需任何建议,请尝试:(这是错误的。请参阅下面的更新)
更新 没有
replaceWord
功能。接口中定义了replaceWord
函数。但是,您可以尝试使用下面的代码覆盖InlineSpellCheckerUI
中的replaceMisspelling
函数。我认为这应该符合你的目的
let original_replaceMisspelling = InlineSpellCheckerUI.replaceMisspelling;
InlineSpellCheckerUI.replaceMisspelling = function()
{
// things i would like to do (i.e. set the Cursor to another spot in the editor)
// call of the original function
return original_replaceMisspelling.apply(this, arguments);
};
不幸的是,这没有起作用。我注释掉了原来的函数,但仍然能够替换拼写错误的单词。可能是拼写检查机制使用了另一个函数吗?因为我认为我覆盖了错误的函数-这就成功了。非常感谢你!请参阅的InlineSpellCheckerUI源代码,并尝试查找需要重写的函数。
let original_replaceMisspelling = InlineSpellCheckerUI.replaceMisspelling;
InlineSpellCheckerUI.replaceMisspelling = function()
{
// things i would like to do (i.e. set the Cursor to another spot in the editor)
// call of the original function
return original_replaceMisspelling.apply(this, arguments);
};