使用ie的菜单接口编写自己浏览器插件

 增加ie右键菜单reg文件内容

--------------------

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer/MenuExt/js窗口]
@="f://html//iejstest.htm"
"flags"=dword:00000001

-------------------------------

iejstest.htm的内容

---------------------

<script>


window.onerror = function(sMessage,sUrl,sLine)
{
   var str = "";

    str += " 错误信息:" + sMessage + "/n";

    str += " 错误地址:" + sUrl + "/n";

    str += " 错误行数:" + sLine + "/n";

    str += "<=========调用堆栈=========>/n";

    var func = window.onerror.caller;

    var index = 0;

    while(func!=null){

       str += "第" + index + "个函数:" + func + "/n";

       str += "第" + index + "个函数:参数表:"

       for(var i=0;i<func.arguments.length;i++){

           str += func.arguments[i] + ",";

       }

       str += "/n===================/n";

       func = func.caller;

       index++;

    }

    document.title = "出错了,出错信息已复制到粘贴板中了.";
    window.clipboardData.setData("Text",str);
   
   return true;
}

</script>
<html style="width:500px;height:175px; font-size :12px; background-color:Silver; overflow:scroll;">
<meta http-equiv=content-type content="text/html; charset=gb2312">
<title>其它+js测试窗口(主窗口是win,此标离开对象是obj;CTRL+ENTER运行)</title>
<style>
#menuA
{
  text-decoration: none;
  border:0px;
  background:transparent;
  color:black;
  display:block;
  margin:2px;
}
#menuA:hover {
  border:1px solid #0a246a;
  background:#316ac5;
        }

</style>
<body topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0
οncοntextmenu="$e('myMune').style.display='block'; $e('muneB').focus();return false;">
<div id=showDiv style="width:100%; height:100%;overflow-y:auto; overflow-x:hidden; word-wrap :break-word; text-align:center; border:0px;">
<textarea id=jsinput style="width:100%; height:100%; word-break:keep-all;overflow:scroll;" οnkeypress="if (event.keyCode == 10
) {eval(this.value)}">
//this.value = obj.outerHTML;

</textarea>
</div>

 


<div id=colorBar style="display:none;">
请在三色条中点下左键后不放,然后拉动调配颜色<br>
在下框输入变色表达式(调用颜色用setColor.rgbColor)
<input id=setColor style="width:100%;" value="obj.style.color = setColor.rgbColor;" rgbColor=""><br>
<input id=redColor value=0  on=0 οnmοusedοwn="this.on=1;"
onmousemove ="changeColorName(this);" οnmοuseup="this.on=0;" 
οnmοuseοut="this.on=0;"
style="cursor:default; width:260px; background: red; text-align:center; "
contenteditable=false UNSELECTABLE=on><BR>
<input id=blueColor value=0  on=0 οnmοusedοwn="this.on=1;"
onmousemove ="changeColorName(this);" οnmοuseup="this.on=0;"
οnmοuseοut="this.on=0;"
style="cursor:default; width:260px; background: blue; text-align:center;"
contenteditable=false UNSELECTABLE=on><br>
<input id=greenColor value=0  on=0 οnmοusedοwn="this.on=1;"
onmousemove ="changeColorName(this);" οnmοuseup="this.on=0;"
οnmοuseοut="this.on=0;"
style="cursor:default; width:260px; background: green; text-align:center;"
contenteditable=false UNSELECTABLE=on>
</div>


<div id=myMune style="display:none; position:absolute;
 border:1px solid #808080;
 height:170px; width:170px;  color:black;
background:#d4d0c8; font-size:13px; font-family:'宋体';
 padding:2px 2px 2px 2px; cursor:default;
top:3px; left:3px;" >
<span id=muneB οnblur="setTimeout('myMune.style.display=/'none/';', 200);" style="line-height:0px; width:0px; height:0px; " TABINDEX=1> </span>

 <span id="menuSpan" style="display:block; width:100%; height:160px;
 overflow-y:scroll;" οnclick="runMenu()">
     <a href=# id=menuA>自动填表</a>
     <a href=# id=menuA>取得数独数字</a>
     <a href=# id=menuA>显示对象属性</a>
     <a href=# id=menuA>选中字英译中</a>
     <a href=# id=menuA>显示调色板</a>
     <a href=# id=menuA>打开源文件</a>
     <a href=# id=menuA>google翻译剪贴板网页</a>
     <a href=# id=menuA>新窗口打开</a>
     <a href=# id=menuA>查询南宁公交</a>
     <a href=# id=menuA>快播查找</a>
     <a href=# id=menuA>破解www.8775.com播放器时间限制</a>   
     <a href=# id=menuA>对象参数</a>        
     <a href=# id=menuA>输入qq号码</a>       
     <a href=# id=menuA>输入qq密码</a>    
 </span>
</div>
            
<script language="javascript">

var win = external.menuArguments;
var obj = external.menuArguments.event.srcElement;

//公用
function getSelectText()
{
  if (win.document.selection.type == "Text")
  {
     return win.document.selection.createRange().text;
  }else
   {
      document.title = "请先选择文字";
      return null;
   }
}

//公用

function changeColorName(colorBar)
{//设置颜色面板
   var colorNumber = event.x - colorBar.offsetLeft - 2;
  
  if (
      (colorBar.on == "1")
   && (colorNumber > -1)
   && (colorNumber < 251)
     )
  {
   colorBar.value = colorNumber;
   setColor.rgbColor = "RGB(" + redColor.value + ", " + blueColor.value + ", " + greenColor.value + ")";
   setColor.style.backgroundColor = setColor.rgbColor;
   eval(setColor.value);
  }

}


function transelect()
{
    var tranText = "";
   
    if(win.document.selection.type == "Text")
    {
       tranText = win.document.selection.createRange().text;
    }
   
    do
    {
      tranText = prompt("请在下框输入或修改要翻译的英文(只接受至少一个或以上的a-z组成的字符串)", tranText);
    }while ( (tranText != null) && (!/^[a-zA-Z]+$/.test(tranText)) )
   
    if (tranText != null)
    {   
     if(typeof(win.tranform) != "object")
     {
      var newform  = win.document.createElement("FORM");
      win.document.body.insertAdjacentElement("afterBegin",newform);
      newform.id = "tranform";
      newform.action = "http://translate.google.com/translate_t?langpair=en|zh-CN";
      newform.method = "post";
      newform.target = "_tranwin";
      newform.innerHTML = '<INPUT type=hidden value=en name=hl><INPUT type=hidden value=UTF8 name=ie>'
                        + '<input id=source dir=ltr name=text>';
    }

    win.tranform.source.value = traninput.value;
    win.tranform.submit();
   }
}

function getForm()
{

try
 {
    for(var formObj = obj; formObj.tagName != "FORM"; )
    {
        formObj = formObj.parentElement;
    }
 }catch(e)
  {
     return window.close();
   }

 checkInput(formObj.elements);
}

function checkInput(formObj)
{
  var inputId;
  var pass = "password";
  var myId = "id";
  var email = "id@email.com";

  for (var inputIndex = 0; inputIndex<formObj.length; ++inputIndex)
  {
      if (formObj[inputIndex].id == formObj[inputIndex].name)
      {
         inputId = formObj[inputIndex].id;
      }else if (formObj[inputIndex].id == "")
       {
         inputId = formObj[inputIndex].name; 
       }else
        {
           inputId = formObj[inputIndex].id;
        }

      switch (formObj[inputIndex].type)
      {    
            case "password": //密码
                 formObj[inputIndex].value = pass;
                 break;
            case "text":
                 if ( (/e.*mail/gi.test(inputId)) )
                 {//email
                      formObj[inputIndex].value = email;
                 }else if ( (/(user)|(name)|(id)|(nickname)|(nick)/gi.test(inputId)) )
                  {//id
                      formObj[inputIndex].value = myId;
                      myId = "";
                  }else if(formObj[inputIndex].outerHTML=='<INPUT class=input-style1 οnkeypress=db(0); style="DISPLAY: block" maxLength=12>')
                   {
                   formObj[inputIndex].value = myId;
                   }else if(formObj[inputIndex].outerHTML=='<INPUT class=input-style1 οnkeypress=db(1); style="DISPLAY: block" maxLength=3>')
                   {
                      formObj[inputIndex].value = "26";
                   }

                 break;
            case "select-one":
                 try{
                  obj.options[0].selected = true;
                 }catch(e){}
                  break;
            default:
                 break;
      }
  }

  window.close();
}

function runExe(path)

    var wshshell = new ActiveXObject("WScript.Shell");
    wshshell.run('d:/progra~1/notepad/Notepad2.exe "' + path);
    wshshell = null;
}


function getNumber()
{
var table = obj.parentElement.parentElement.parentElement.parentElement;
//this.value =(obj.parentElement.parentElement.parentElement.parentElement.outerHTML);
var rowI = cellI = 0;
var get = new Array();

for (var forI = forII = 0; forI < table.rows.length; forI++)
{
   for (forII = 0; forII < table.rows[forI].cells.length; forII++)
    {
       try
       {
          if (table.rows[forI].cells[forII].innerHTML.indexOf("INPUT") > -1)
          {
             if (cellI > 8)
             {
               cellI = 0;
               rowI++;
             }

             if (table.rows[forI].cells[forII].lastChild.value * 1 > 0)
             {
                get[get.length] = rowI + "" + cellI + table.rows[forI].cells[forII].lastChild.value ;
             }
              
               cellI++;
         }
        }catch(e){}
     }
}


window.clipboardData.setData("Text",'/n<option value="' + get.join(",") + '">/n' + win.document.getElementsByName("puzzle_num_reset")[0].value + '</option>');
alert("已保存在剪贴板中。");


}

function forObj(objStr)
{//获取选中对象的属性

    if (objStr != null)
    {
      var proText = "";
 
      for (var pro in eval(objStr))
      {
        try
        {
          proText += objStr + "." + pro + " = " + eval(objStr + "." + pro) + "/n";
        }catch(E)
         {
            ;
         }
      }
 
      jsinput.value = proText;
    }
}

function googleC()
{
  var text = window.clipboardData.getData("Text");
  text = text.replace(//:/g,"%3A");//:
  text = text.replace(g,"%2F");///
  text = text.replace(g,"%5C");///
  win.open( "http://translate.google.cn/translate?prev=&hl=zh-CN&ie=UTF-8&sl=en&tl=zh-CN&history_state0=&u=" + text);
  window.close();
}

function showBus()
{
    document.getElementsByName("showDiv")[0].innerHTML = '<INPUT id=q1 maxLength=100 size=30> - <INPUT id=q2 maxLength=100 size=30>'
    + '<input type=button value=查询路线 οnclick="win.open(/'http://nanning.8684.cn/so.php?k=pp&q=/' + q1.value); window.close();">'
    + '<input type=button value=查询站点 οnclick="win.open(win.location.href = /'http://nanning.8684.cn/so.php?k=p&q=/' + q1.value); window.close();">'
    + '<input type=button value=换乘方案 οnclick="win.open(win.location.href = /'http://nanning.8684.cn/so.php?k=p2p&q=/' + q1.value + /'&q1=/' + q2.value); window.close();">';
}

function Search4577()
{
  var selectText = getSelectText();
 
  if (selectText != null)
  {
     win.open("http://www.qvodsou.com/search/search.do?q=" + selectText);
     window.close();  
  }
}

function playSong()
{
   win.video.outerHTML = '<OBJECT ID="video"  CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'
                       + ' <PARAM name="autoStart" value="True">'
                       + ' <PARAM name="volume" value="100">'
                       + ' <PARAM name="playCount" value="1">'
                       + '</OBJECT>';
   var playSongFun =function (checkI,playI)
   {  
    if ((checkI != -1))playI = checkI;
    if (
         (video.playState == 1)
       ||(video.playState == 8)
       ||(video.playState == 0)
       ||(checkI != -1)
       )
    {
       if(playI >= document.getElementsByName("checkbox").length)playI = 0;
       document.title ="播放" + document.getElementsByName("checkbox")[playI].value;
       video.URL = mp3 + document.getElementsByName("checkbox")[playI].value;      
       playI++;
       video.Controls.play();
     }
     clearTimeout(window.timer);
     window.timer = setTimeout("nologin2(-1," + playI + ");",1000);
   }
   win.eval('mp3 = "http://" + playTran2.toString().split(");  
   win.eval(playSongFun.toString().replace("function","function nologin2"));
   win.eval("setTimeout('nologin2(-1,0);',1000)");
   window.close();
}

function newWin()
{
     var selectText = getSelectText();
    
     if (selectText != null)
     {
         if (/^ *http/:/gi.test(selectText) == false)
         {
           selectText = "

http://www.google.cn/search?hl=zh-CN&lr=&q=" + selectText;
         }
    
         win.open(selectText);
         window.close();
     }
}

function runMenu()
{
        var obj = event.srcElement;
       
        if (obj.tagName != "A")
        {
           return false;
        }
       
        switch(obj.innerText)
        {
           case "取得数独数字":
               getNumber();
               break;
           case "显示对象属性":
               jsinput.value = "forObj('');//在单引号内输入对象名";
               break;
           case "选中字英译中":
               transelect();
               break;
           case "打开源文件":
               runExe(location.pathname);
               break;
           case "自动填表":
               getForm();
               break;
           case "显示调色板":
               colorBar.style.display = "inline";
               break;
           case "google翻译剪贴板网页":
               googleC();
               break;  
           case "新窗口打开":
                newWin();
                break; 
           case "查询南宁公交":
                showBus();
                break;  
           case "快播查找":
                Search4577();
                break;  
           case "破解www.8775.com播放器时间限制":
                playSong();
                break;
           case "对象参数":
                forObj("obj");
                break;
           case "输入qq号码":
                alert(obj.value)
                obj.value="80250771";
                break;
           case "输入qq密码":
                obj.value="80250771";
                break;
           default:
              alert("找不到对应操作方式!请先添加!");          
        }
}

 

function $e(objId)
{
  return document.getElementById(objId);
}
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值