首先,是学校的教务网页使用了innerText属性,所以我想自己写一个UserScript脚本来实现innerText属性。如何使用Scriptish向火狐添加innerText属性?
如何使用Scriptish
其实,只要执行如下脚本后,就有了innerText属性了:
if(!!document.getBoxObjectFor||window.mozInnerScreenX!=null){
HTMLElement.prototype.__defineGetter__("innerText",function(){
returnthis.textContent;
});
HTMLElement.prototype.__defineSetter__("innerText",function(value){
this.textContent=value;
});
}
但是,我自己写了脚本之后,仍然无法设置innerText属性,提示TypeError:HTMLElement.prototype.__defineGetter__isnotafunction
请问如何解决?
另外,innerText属性在onload代码中就使用了。
我觉得Scriptish的权限控制也是需要考虑的。
Scriptish权限
附上我写的测试脚本:
//==UserScript==
//==/UserScript==
if(!!document.getBoxObjectFor||window.mozInnerScreenX!=null){
HTMLElement.prototype.__defineGetter__("innerText",function(){
returnthis.textContent;
});
HTMLElement.prototype.__defineSetter__("innerText",function(value){
this.textContent=value;
});
}
总之,如何使用Scriptish给大家简单的介绍了一些,希望大家多看看。