简单几行JS Code实现IE邮件转发新浪微博
2013-07-03 00:00
525 查看
最近刚开通新浪围脖,突发奇想,想做个浏览器插件实现文字新闻等的转发围脖的插件。本以为应该用C++写个插件的(c#那么大个壳有时真的让人头疼),但是google了一下,手气真的不错,搜到了,几篇关于IE插件的开发。用的Javascript,和添加注册表就可以完全搞定。插件用javascript写那就不用多说,浏览器本身就支持的,不用额外安装。添加注册表手动可以添加,但是麻烦所以写了一个批处理搞定。
1:添加注册表:HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\<Menu Text> 设置默认值为html文件路径,添加值Contexts为)0xf3.
2:code : 在MSDN http://msdn.microsoft.com/en-us/library/aa753589(v=VS.85).aspx中有所讲解。MSDN原文:Set the default value of the key to the URL of the page that contains the script you want the context menu entry to execute. This script can obtain the parent window object, the screen where the context menu item was executed, from the menuArguments property of the external object.
大概就是说我们可以用window.external.menuArguments这个对象获取到内部的信息,如window,document这些常用的对象。所以我们就可以马上开工了,三下五去二不几分钟就搞定(代码很简单就直接Code了):
看一个效果:
缺点:在这里只是简单获取的下文本值的内容,还没有找到获取选中html或者对象的方式,正在查找,如果有知道的请不吝赐教。我打算是可以解析出视频,图片等,发送。
下载【直接点击批处理运行,重启IE】
参考文献:
http://msdn.microsoft.com/en-us/library/aa753589(v=VS.85).aspx
http://blogs.msdn.com/b/oldnewthing/archive/2004/05/24/140283.aspx
1:添加注册表:HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\<Menu Text> 设置默认值为html文件路径,添加值Contexts为)0xf3.
2:code : 在MSDN http://msdn.microsoft.com/en-us/library/aa753589(v=VS.85).aspx中有所讲解。MSDN原文:Set the default value of the key to the URL of the page that contains the script you want the context menu entry to execute. This script can obtain the parent window object, the screen where the context menu item was executed, from the menuArguments property of the external object.
大概就是说我们可以用window.external.menuArguments这个对象获取到内部的信息,如window,document这些常用的对象。所以我们就可以马上开工了,三下五去二不几分钟就搞定(代码很简单就直接Code了):
<SCRIPT LANGUAGE = "JavaScript"> var oWindow = window.external.menuArguments; var oDocument = oWindow.document; var oSelect = oDocument.selection; var oSelectRange = oSelect.createRange(); var sNewText = oSelectRange.text;//.substring(0,140); var title=sNewText.length == 0?oDocument.title:sNewText; if (title.length>0){ oWindow.open("http://service.weibo.com/share/share.php?title="+encodeURIComponent(title)+"&url="+encodeURIComponent(oDocument.URL)+"&source="+encodeURIComponent("破 狼")+"&appkey=1027675428&sourceUrl="+encodeURIComponent(oDocument.URL)); } </SCRIPT>
看一个效果:
缺点:在这里只是简单获取的下文本值的内容,还没有找到获取选中html或者对象的方式,正在查找,如果有知道的请不吝赐教。我打算是可以解析出视频,图片等,发送。
下载【直接点击批处理运行,重启IE】
参考文献:
http://msdn.microsoft.com/en-us/library/aa753589(v=VS.85).aspx
http://blogs.msdn.com/b/oldnewthing/archive/2004/05/24/140283.aspx
相关文章推荐
- 简单几行JS Code实现IE邮件转发新浪微博
- 简单几行JS Code实现IE邮件转发新浪微博
- 简单几行JS Code实现IE邮件转发新浪微博
- 一个超简单的JS拖拽实现代码(兼容IE,Firefox)
- Java中使用SimpleEmail实现简单邮件的发送
- JAVA邮件发送的简单实现
- C语言实现简单的SMTP发送邮件
- Java实现简单邮件发送
- 几行简单代码实现DIV层上显示Tooltip效果
- iOS开发>学无止境 - 新浪微博iOS底部功能按钮简单实现
- Java 超简单实现发送邮件(可动态控制发送人数)
- JAVA邮件发送的简单实现
- Python实现的简单发送邮件脚本分享
- java邮件发送简单实现代码
- Java发送邮件的简单实现
- C语言实现简单的SMTP发送邮件
- 简单的新浪微博OAuth认证实现
- C和C#两种方式实现简单的邮件发送
- 利用Pillow,几行代码实现的最简单的Django页面验证码功能
- 【Netty4 简单项目实践】八、转发服务的实现方案