Recently, I just opened Sina Weibo and wanted to create a browser plug-in to forward text news and so on. I thought I should use C ++ to write a plug-in (c # is so big, sometimes it is really a headache), but google, it's really good, I found it, several articles about the development of IE Plug-ins. Use Javascript, and add the registry. If the plug-in is written in javascript, you don't need to talk about it. The browser itself supports it and does not need to install it. You can add a registry manually, but it is troublesome to write a batch.
1: add the Registry: HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ MenuExt \ <Menu Text>. Set the default value to the html file path and the value Contexts to) 0xf3.
2: code: explained in MSDN http://msdn.microsoft.com/en-us/library/aa753589 (v = VS.85). aspx. MSDN Original: 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.
We can use the window. external. menuArguments object to obtain internal information, such as common objects such as window and document. So we can get started right away, and we can get it done in the next five or five minutes (the Code is simple and you can directly Code it ):
Copy codeThe Code is as follows:
<Script language = "JavaScript">
Var oWindow = window. external. menuArguments;
Var oDocument = ow.20.doc ument;
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 (" broken
Wolf ") +" & appkey = 1027675428 & sourceUrl = "+ encodeURIComponent (oDocument. URL ));
}
</SCRIPT>
See the following results:
Disadvantages: here is just a simple way to get the content of the text value. You have not found the method to get the selected html or object. You are looking for it. If you know it, please do not hesitate to give it a try. I plan to parse and send videos and images.
Download [Click batch processing to run and restart IE]
References:
Http://msdn.microsoft.com/en-us/library/aa753589 (v = VS.85). aspx
Http://blogs.msdn.com/ B /oldnewthing/archive/2004/05/24/140283.aspx