ページ内の任意の文字列を置換する

やっつけです。画面左上に入力ボックスが出ます。ブックマークレットにすると良いかもです。

(function(){
   function $id(){
     var elem, id;
     switch(arguments.length){
     case 1:  elem = document    ; id = arguments[0]; break;
     case 2:  elem = arguments[0]; id = arguments[1]; break;
     default: throw "argument error";
     }
     return elem.getElementById(id);
   }

   function createElement(parent, tagName, attributes, styles, innerHTML){
     var e = document.createElement(tagName);
     if(attributes){
       for(var key in attributes){
         e.setAttribute( key, attributes[key] ); }}
     if(styles){
       for(var key in styles){
         e.style[key] = styles[key]; }}
     if(innerHTML){
       e.innerHTML = innerHTML; }
     if(parent){
       parent.appendChild(e); }

     return e;
   }

   var box = createElement(
     document.body
     , "form"
     , null
     , { position: "fixed"
         , left: 0
         , top: 0
         , background: "#ddd"
         , padding: "4px"
         , border: "solid 1px black"
       }
     , null
   );

   var inputMatch = createElement(box, "input", { id: "match" }, { display: "block" }, null );
   inputMatch.focus();

   var inputReplace = createElement(box, "input", { id: "replace" }, { display: "block" }, null);

   var button = createElement(
     box
     , "input"
     , { type: "submit", value: "replace" }
     , null
     , null
   );
   button.addEventListener(
     "click"
     , function(e){ traverse(document
                             , $id("match").value
                             , $id("replace").value);
                    e.preventDefault();
                  }
     , false
   );

   var buttonDelete = createElement(
     box
     , "input"
     , { type: "button", value: "x" }
     , null, null
   );
   buttonDelete.addEventListener(
     "click"
     , function(){ document.body.removeChild( box ); }
     , false
   );

   function traverse(elem, matchString, replaceString){
     var kids = elem.childNodes;

     var kid;
     for(var a=0; a<kids.length; a++){
       kid = kids.item(a);
       if(kid.nodeType == 3){
         kid.nodeValue = kid.nodeValue
           .replace(matchString, replaceString);
       }else{
         if(kid.childNodes.length>0){
           traverse(kid, matchString, replaceString);
         }
       }
     }
   }
 })();