相关疑难解决方法(0)

检索和修改XMLHttpRequest的内容

我正在开发一个针对Firefox,Safari,Chrome的浏览器插件,它将拦截页面上的数据,针对正则表达式运行它,然后如果它匹配 - 重新格式化它.我有这个工作在页面加载使用:

var meth = {
  replaceInElement : function(element, find, replace) {
        // iterate over child nodes and replace
  },
  run : function(evt){
    // doc is the document that triggered "run" event
    if (!(evt.target.nodeName === "#document")) { return; }
    var doc = evt.target; // document that triggered "onload" event
    if (!(doc instanceof HTMLDocument)) { return; }
    if (!doc.location) { return; }

    // perform substitutions on the loaded document
    var find = /regex/gi

    meth.replaceInElement(doc.body, find, function(match) {
        var new_content;
        //do …
Run Code Online (Sandbox Code Playgroud)

javascript xmlhttprequest firefox-addon addeventlistener google-chrome-extension

7
推荐指数
1
解决办法
2964
查看次数