﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>学习日记 &#187; 浏览器插件开发</title>
	<atom:link href="https://www.softwareace.cn/?cat=7&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://www.softwareace.cn</link>
	<description>时刻想着为自己的产品多做一些对他好的事情</description>
	<lastBuildDate>Fri, 20 Mar 2026 06:58:28 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>NPAPI和PPAPI开发</title>
		<link>https://www.softwareace.cn/?p=1435</link>
		<comments>https://www.softwareace.cn/?p=1435#comments</comments>
		<pubDate>Wed, 17 Feb 2016 06:13:36 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1435</guid>
		<description><![CDATA[http://blog.csdn.net/lee353086/article/details/49302917 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>http://blog.csdn.net/lee353086/article/details/49302917</p>
<h1>NPAPI和PPAPI开发</h1>
<p>Author: kagula</p>
<p>Revison: 1<br />
Last modify date：2015-10-20</p>
<h2><a style="color: #336699;" name="t1"></a><strong>环境：</strong></h2>
<p>[1]Visual Studio 2010 SP1<br />
Visaul Stuio  2013 Update4<br />
[2]Python2.7<br />
[3]Firefox 41.0.1<br />
[4]IE 11<br />
[5]Google chrome 45.0.2454.101<br />
[6]Opera 32.0<br />
[7]360浏览器 7.1.1.808<br />
[8]nacl sdk pepper39<br />
[9]windows7 SP1 64bits</p>
<h2><a style="color: #336699;" name="t2"></a><strong>关键词</strong></h2>
<p>Firebreath, NPAPI, PPAPI, Web worker, Messaging System, Native Client Module, Application Structure<br />
Chrome Web Store, portable executable file, architecture-specific executable file</p>
<h2><a style="color: #336699;" name="t3"></a><strong>前言 </strong></h2>
<p>如果要实现Windows平台，跨不同浏览器插件，就需要分别实现<br />
ActiveX  适用浏览器IE11，因为IE11对FireBreath兼容性不是很好。<br />
FreBreath(NPAPI)  适用浏览器,360浏览器，Chrome 42版本以下，Opera、Firefox。<br />
NaCl(可分为PPAPI、NaCl、PNaCl三个等级) 适用浏览器Chrome 42版本或以上。<br />
ActiveX的baidu上很多，但是NPAPI和PPAPI的很不完善，所以这里仅仅介绍NPAPI和PPAPI的开发。<br />
<img src="http://img.blog.csdn.net/20151026090949743" alt="" /></p>
<h2><a style="color: #336699;" name="t4"></a><strong>第一部份：NPAPI</strong></h2>
<p><strong>第一个插件(NPAPI)：</strong><br />
firebreath是个跨浏览器插件开发工具，所以先尝试FireBreath。<br />
<strong>Step1:</strong><br />
参考资料[3]下载firebreath最新稳定版本，并解压到“D:\SDK\firebreath-FireBreath-105dcc6\”目录下<br />
从官网上下载firebreath-boost-1.50.0.zip<br />
位置参考下面摆放：<br />
&lt;FB_ROOT&gt;/src/3rdParty/boost/boost/<br />
&lt;FB_ROOT&gt;/src/3rdParty/boost/libs/</p>
<p><strong>Step2</strong>:先建一个Hello工程。<br />
打开控制台，切换到“D:\SDK\firebreath-FireBreath-105dcc6”文件夹，<br />
输入命令“python fbgen.py”根据提示输入你第一个工程plugin name,plugin description,company name等信息。<br />
命令执行完毕后，再调用“prep2010.cmd”命令。<br />
python就在当前build子目录下建好了VS2010 solution，FireBreath.sln文件。<br />
打开sln后应该就能正确编译。如果有问题参考资料[1]。</p>
<p><strong>Step3</strong>:测试插件是否正确加载。<br />
[S3-1]IE下运行插件。<br />
命令行方式转到“D:\SDK\firebreath-FireBreath-105dcc6\build\bin\hello\Debug”路径下，使用“regsvr32 nphello.dll”注册控件。<br />
&#8220;D:\SDK\firebreath-FireBreath-105dcc6\build\projects\hello\gen&#8221;路径下打开“FBControl.htm”文件，就可以在IE中正常运行hello控件。<br />
如果有问题，参考资料[2]。<br />
[S3-2]Firefox下运行插件<br />
我是把dll复制到“C:\Users\kagula\AppData\Roaming\Mozilla\Firefox\Profiles\ie1ypj6h.default\plugins”路径就Ok了，如果没有“plugins”目录就新建一个。<br />
不同的计算机Win7下，参考下面的格式就Ok了。<br />
“C:\Users\XXX\AppData\Roaming\Mozilla\Firefox\Profiles\XXX.default\plugins”<br />
[S3-3]Chrome下运行<br />
Chrome 45 不支持NPAPI。<br />
[S3-4]Opera下运行<br />
使用“regsvr32 nphello.dll”注册控件后，可以直接使用，<br />
但是会提示“此网站使用的插件很快将不被支持”<br />
[S3-5]360浏览器下运行<br />
使用“regsvr32 nphello.dll”注册控件后，可以直接使用，</p>
<p><strong>Step4</strong>:测试插件功能是否正常<br />
[1]hello.cpp的FB::JSAPIPtr hello::createJSAPI()函数，创建了helloAPI实例返回。<br />
查看helloAPI实现，<br />
echo方法用来示例参数传递，testEvent方法示例事件回调，testString和version示例如何存取对象的属性。<br />
[2]FBControl.htm文件，点击“Fire a test event”会间接调用helloAPI实例的testEvent方法，这个方法又会激活JS的test事件。<br />
在IE中没有反应，但是在Opera和360浏览器中测试正常。<br />
[3]FBControl.htm文件，点击“Activate click counter”，就多一次对插件echo事件的绑定。<br />
然后，再点击“Click me!”，JS会调用插件的echo方法，而插件的echo方法会调用js对echo事件的绑定function。<br />
在IE中依旧没有反应。<br />
[4]测试插件属性的存取，<br />
[S4-1]为FBControl.htm文件，添加一个js函数。<br />
function testPluginPropertyAccess()<br />
{<br />
alert(plugin().testString);<br />
plugin().testString = &#8220;插件属性的默认值已经被JS修改&#8221;;<br />
alert(plugin().testString);<br />
}<br />
为FBControl.htm文件，添加一个链接，可以让用户点击。<br />
&lt;a href=&#8221;#&#8221; onclick=&#8221;javascript:testPluginPropertyAccess()&#8221;&gt;测试对属性值的修改&lt;/a&gt; &lt;br /&gt;<br />
[S4-2]修改helloAPI.h文件，在helloAPI的构造函数中添加下面的代码。<br />
m_testString = &#8220;Default value in c++&#8221;;<br />
这样我们才能知道这个属性的值是来自C++代码的。<br />
[S4-3]然后再参考上文，测试即可。<br />
[<strong>Step5</strong>]验证是否能自绘区域<br />
一开始在&#8221;hello&#8221;项目上onWindowAttached死活不会来，后来又重建了一个firegbreath项目就好了。<br />
猜测是用fbgen.py新建项目时，输入的参数不对。<br />
下面是我的测试函数，我往plugin api里注册了“draw”函数，用来测试能否绘制html表面。<br />
void helloAPI::draw()<br />
{<br />
if (_wnd) {<br />
HDC hDC = GetDC(_wnd-&gt;getHWND());</p>
<p>RECT rect;<br />
rect.left=0,rect.top=0,rect.right=256,rect.bottom=256;</p>
<p>HBRUSH hbr;<br />
hbr = CreateSolidBrush(RGB(255,0,0));<br />
FillRect(hDC,&amp;rect,hbr);</p>
<p>ReleaseDC(_wnd-&gt;getHWND(),hDC);<br />
}<br />
}</p>
<p>具体参考“&#8230;\firebreath-FireBreath-105dcc6\examples\BasicMediaPlayer”目录下的源代码。</p>
<p>备注<br />
[1]Firebreath缺省没有连接下面两个事件：<br />
EVENTTYPE_CASE(FB::RefreshEvent, draw, FB::PluginWindow);<br />
EVENTTYPE_CASE(FB::WindowsEvent, onWindowEvent, FB::PluginWindow)</p>
<h2><a style="color: #336699;" name="t5"></a>第二部份：PPAPI</h2>
<p>Chrome插件只能使用PPAPI接口的Native Client(NaCl)方式编写，<br />
Native Client分别有三种embed类型<br />
“application/x-ppapi”，平台相关，唯一能直接使用win32 api的platfrom（有功能上的限制）。  dll格式，<br />
不允许通过Chrome web store分发。据说Flash就是采用第一种类型开发的。<br />
“application/x-nacl”， 只能通过PPAPI，平台无关，cpu相关。nexe格式，只能通过Chrome web store分发。<br />
“application/x-pnacl”，只能通过PPAPI，平台无关，cpu无关。pexe格式，可以不通过Chrome web store分发。<br />
为了减少麻烦，建议系统只安装Visual Studo 2010版。</p>
<p>跟着官网先学习第一个PPAPI插件(Native Client)的开发流程<br />
首先参考<br />
《C++ Tutorial: Getting Started 》</p>
<p>https://developer.chrome.com/native-client/devguide/tutorial/tutorial-part1</p>
<p>建立，运行，修改自己的第一个portable native client程序，这样就先有了个概念。<br />
按照tutorial一步步走是没有问题了，但是</p>
<p><strong>如何在VS中开发、调试native client程序？</strong><br />
你需要为nacl sdk安装vs_addin。<br />
官网文档上说vs_addin只支持vs2010sp1和vs2012，但是经过修改能支持vs2013，但是不建议折腾。<br />
<strong>[Step1]</strong>设置当前计算机用户变量<br />
NACL_SDK_ROOT环境变量为“E:\SDK\nacl_sdk\pepper_39”。<br />
CHROME_PATH环境变量为“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”。<br />
<strong>[Step2]</strong>管理员权限启动控制台转到“E:\SDK\nacl_sdk\vs_addin”路径下，输入“Install”命令安装“vs_addin”。<br />
以后你还可以通过输入“Install  &#8211;uninstall”命令来反安装。<br />
<strong>[FinalStep-PPAPI]</strong>现在可以转到“E:\SDK\nacl_sdk\vs_addin\examples\hello_world_gles”目录，使用VS2010打开hello_world_gles solution。<br />
platform从默认“NaCI32”改为“PPAPI”即可编译通过，会在当前project路径下产生win目录，win目录下会生成hello_world_gles.dll文件。<br />
直接按[F5]就可以Debug這個dll，在VisualStudio中进入断点。<br />
<strong>[FinalStep-NaCl64]</strong>platform从默认“NaCI32”改为“NaCI64”,<br />
project property page should be<br />
[General]-&gt;[Native Client]-&gt;[IndexPage of NaCl Application]-&gt;[index_newlib.html]<br />
[General]-&gt;[Native Client]-&gt;[Toolchain]-&gt;[newlib]<br />
在当前项目NaCl64\newlib\Debug路径下只生成一个hello_world_gles_64.nexe文件，所以调试针对的是这个文件。<br />
由于这个文件是虚拟代码（据说运行前会转成机器码）所以只能用nacl sdk带的gdb来调试。<br />
[F5]启动Debug，默认打开index_newlib.html页面，启动gdb控制台后就可以命令行方式调试了。<br />
你可能需要设置chrome启用NaCl，授权Chrome能够使用未经Chrome Web Store发布的nexe文件。<br />
<strong>[FinalStep-PNaCl]</strong>platform从默认“NaCI32”改为“PNaCl”，会在当前项目下编译输出一个pexe文件和三个针对不同cpu的nexe文件，VS中[F5]不会进入Debug、break模式。</p>
<p>备注：<br />
[1]具体参考官方vs-addin文档。  https://developers.google.com/native-client/dev/devguide/devcycle/vs-addin<br />
[2]在啟動chrome調試前，勾選F12-&gt;Settins-&gt;General-&gt;Disable cache（while DevTools is open）防止html緩存。</p>
<p><strong>如何部署pexe格式控件到chrome上？</strong><br />
[Step1]先检查PNaCI是否在chrome中启用（默认已经安装）<br />
在chrome中addressbar中使用“chrome://nacl/”查看是否允许PNaCI插件。如果没有安装相应component，可以输入“chrome://components”在compoennts页面中安装或更新。<br />
[Step2]假设&#8221;E:\nginx-1.8.0\html&#8221;是你Web服务器的webroot路径，把“E:\SDK\nacl_sdk\pepper_39\getting_started\part1”目录下的<br />
hello_tutorial.nmf和hello_tutorial.pexe两个文件复制到&#8221;E:\nginx-1.8.0\html&#8221;。把“index.html”重命名为“hello_tutorial.html”并复制到webroot路径中。<br />
现在你的webroot路径中已经有了“hello_tutorial.nmf”、“hello_tutorial.pexe”和“hello_tutorial.html”三个文件。<br />
[FinalStep]在chorme中输入“http://localhost:8080/hello_tutorial.html”打开pexe测试页面，测试成功。</p>
<p><strong>如何运行vs_addin自带的hello_nacl_cpp项目？</strong><br />
[Step1]用vs2010打开hello_nacl_cpp项目后，修改好代码后，选择PNaCl平台编译出pexe和nexe文件。<br />
[Step2]在“E:\SDK\nacl_sdk\pepper_39\examples”路径下新建“hello_nacl_cpp”目录。<br />
[Step3]复制“E:\SDK\nacl_sdk\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\PNaCl\newlib\Debug”路径下的pexe、nexe扩展名的四个文件<br />
到新建的“E:\SDK\nacl_sdk\pepper_39\examples\hello_nacl_cpp”路径下面。<br />
复制“E:\SDK\nacl_sdk\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\index.html”文件到新的路径下。<br />
复制“E:\SDK\nacl_sdk\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\PNaCl\hello_nacl_cpp.nmf”文件到新的路径下。<br />
[Step4]修改新路径下的index.html，把embed元素中的type属性从“application/x-nacl”改为“application/x-pnacl”。<br />
因为PNaCl插件mime type只能为“application/x-pnacl”。<br />
修改新路径下的hello_nacl_cpp.nmf文件，使之支持pexe，并能从当前目录读取pexe文件，修改后的内容如下：<br />
{<br />
&#8220;files&#8221;: {},<br />
&#8220;program&#8221;: {<br />
&#8220;portable&#8221;: {<br />
&#8220;pnacl-translate&#8221;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp.pexe&#8221;<br />
}<br />
},<br />
&#8220;x86-64&#8243;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp_64.nexe&#8221;<br />
},<br />
&#8220;arm&#8221;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp_arm.nexe&#8221;<br />
},<br />
&#8220;x86-32&#8243;: {<br />
&#8220;url&#8221;: &#8220;hello_nacl_cpp_32.nexe&#8221;<br />
}<br />
}<br />
}<br />
[FinalStep-PNaCl方式]<br />
在控制台下启动“E:\SDK\nacl_sdk\pepper_39\examples\httpd.cmd”程序。<br />
在chrome中输入“http://localhost:5103/hello_nacl_cpp/”成功打开测试页面。</p>
<p><strong>如何新建NaCl项目</strong><br />
在visual studio中新建C++ Empty Project<br />
設置項目屬性為[General]-&gt;[Project Defaults]-&gt;[Configuration Type]-&gt;[Dynamic Library(.dll)]。<br />
新建好项目后，就可以添加源代码文件开始编程。<br />
这里没有从新的C++ Dll Empty Project开始，是因为这个wizard会引入很多win32定义导致NaCl64平台编译失败，修改起来太麻烦。</p>
<p>示例代码有两种风格，第一种参考“vs_addin\examples”下的hello_nacl_cpp项目，第二种参考“hello_world_gles”项目，<br />
开发包自带的例子基本上都属于这种风格。<br />
典型的代码如下：</p>
<div class="dp-highlighter bg_cpp">
<div class="bar">
<div class="tools" style="color: silver;"><b>[cpp]</b> <a class="ViewSource" style="color: #a0a0a0;" title="view plain" href="http://blog.csdn.net/lee353086/article/details/49302917#">view plain</a><span class="tracking-ad" data-mod="popu_168"><span class="tracking-ad" data-mod="popu_168"> <a class="CopyToClipboard" style="color: #a0a0a0;" title="copy" href="http://blog.csdn.net/lee353086/article/details/49302917#">copy</a></span></span></p>
<div></div>
</div>
</div>
<ol class="dp-cpp" style="color: #5c5c5c;" start="1">
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="preprocessor" style="color: gray;">#include &#8220;ppapi/cpp/instance.h&#8221;</span>  </span></li>
<li><span style="color: black;"><span class="preprocessor" style="color: gray;">#include &#8220;ppapi/cpp/module.h&#8221;</span>  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="preprocessor" style="color: gray;">#include &#8220;ppapi/cpp/var.h&#8221;</span>  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">class</span> MyInstance : <span class="keyword" style="font-weight: bold; color: #006699;">public</span> pp::Instance {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">public</span>:  </span></li>
<li><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">explicit</span> MyInstance(PP_Instance instance) : pp::Instance(instance)  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    {}  </span></li>
<li><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> ~MyInstance() {}  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> <span class="keyword" style="font-weight: bold; color: #006699;">void</span> HandleMessage(<span class="keyword" style="font-weight: bold; color: #006699;">const</span> pp::Var&amp; var_message) {  </span></li>
<li><span style="color: black;">        <span class="keyword" style="font-weight: bold; color: #006699;">if</span> (var_message.is_string())  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">        {  </span></li>
<li><span style="color: black;">            std::string message = var_message.AsString();  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">            pp::Var var_reply;  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;">            std::string reply = <span class="string" style="color: blue;">&#8220;echo [&#8220;</span>;  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">            reply.append(message);  </span></li>
<li><span style="color: black;">            reply.append(<span class="string" style="color: blue;">&#8221; from my NaCi module&#8221;</span>);  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">            var_reply = pp::Var(reply);  </span></li>
<li><span style="color: black;">            PostMessage(var_reply);  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">        }  </span></li>
<li><span style="color: black;">    }  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">};  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">class</span> MyModule : <span class="keyword" style="font-weight: bold; color: #006699;">public</span> pp::Module {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">public</span>:  </span></li>
<li><span style="color: black;">    MyModule() : pp::Module() {}  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> ~MyModule() {}  </span></li>
<li><span style="color: black;">    <span class="keyword" style="font-weight: bold; color: #006699;">virtual</span> pp::Instance* CreateInstance(PP_Instance instance) {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">        <span class="keyword" style="font-weight: bold; color: #006699;">return</span> <span class="keyword" style="font-weight: bold; color: #006699;">new</span> MyInstance(instance);  </span></li>
<li><span style="color: black;">    }  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">};  </span></li>
<li><span style="color: black;">  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">  </span></li>
<li><span style="color: black;"><span class="keyword" style="font-weight: bold; color: #006699;">namespace</span> pp {  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    Module* CreateModule() {  </span></li>
<li><span style="color: black;">        <span class="keyword" style="font-weight: bold; color: #006699;">return</span> <span class="keyword" style="font-weight: bold; color: #006699;">new</span> MyModule();  </span></li>
<li class="alt" style="color: inherit;"><span style="color: black;">    }  </span></li>
<li><span style="color: black;">}  </span></li>
</ol>
</div>
<p>测试dll、pexe格式的控件用的html和js可以从“hello_world_gles”例子的基础上只要做很小的修改就能测试插件有没有装载成功。<br />
“PPAPI”平台下编译不会fire load事件在html中，导致不会提示成功装载插件的提示，但是实际上“hello_world_gles”插件已经正常运行。<br />
你可能需要修改当前工程的[Configuration Properties]-&gt;[General]-&gt;[Native Client]-&gt;[Index Page of NaCl Application]属性指定html文件名<br />
VS启动Debug的时候会以命令行方式传递给chrome的flags设置。<br />
所以在VS外你要使用nexe文件，需要在Chrome浏览器中输入“chrome://flags/”启用“Native Client”，授权chrome可以使用未经chrome web store发布的native client程序。</p>
<p>备注：<br />
[1]NaCl64启动调试后，在Chrome46中装载控件会失败，导致gdb不能单步跟踪，但是Chrome43没有这个问题。</p>
<p>[参考资料]</p>
<p>https://developer.chrome.com/native-client/devguide/devcycle/debugging</p>
<p>https://developer.chrome.com/native-client/devguide/devcycle/building</p>
<p><strong>如何在vs2013中使用vs2013的native client插件</strong><br />
[Step1] 复制 %user%\Documents\Visual Studio 2012\Addins\ 到 %user%\Documents\Visual Studio 2013\Addins<br />
[Step2] 复制  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\NaCl\  到  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\NaCl\<br />
[FinalStep] 复制 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\ 下的以下文件夹<br />
ARM NaCl32 NaCl64 NaClARM PNaCl PPAPI<br />
到 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\</p>
<p>C:\Users\kagula\AppData\Local\Google\Chrome\User Data<br />
C:\Program Files (x86)\Google\Chrome\Application</p>
<p><strong>如何重新编译NaCi的ppapi_cpp？</strong><br />
打开Visual Studio Command Prompt然后使用下面的命令：<br />
$ cd $NACL_SDK_ROOT\src\ppapi_cpp<br />
$ make TOOLCHAIN=win CONFIG=Debug<br />
$ make TOOLCHAIN=win CONFIG=Release</p>
<p><strong>NaCl Module如何调用Win32 API？</strong><br />
项目只有在“PPAPI”platform下才能直接调用win32 api，虽然能自由调用win32api,<br />
但是调用win32 api创建新的进程，或调用C++ std对本地磁盘进行操作都会失败！<br />
想要自由的使用win32 api只能参考下面的文档来实现，据说是唯一的解决办法。<br />
《Native Messaging》</p>
<p>https://developer.chrome.com/extensions/nativeMessaging</p>
<p>下面解释了“PPAPI”platform的限制。</p>
<p>http://stackoverflow.com/questions/23472077/purpose-of-ppapi-toolchain-and-how-to-use-it?rq=1</p>
<p><strong>JS如何接收来自Native Client的消息</strong><br />
最简单的例子是..\nacl_sdk\vs_addin\examples\hello_nacl\hello_nacl下的index.html源文件。</p>
<p><strong>常见问题</strong><br />
Q 编译项目提示。<br />
Error 1  error MSB6006: &#8220;C:\sdk\nacl_sdk\pepper_39\toolchain\win_x86_newlib\bin\x86_64-nacl-g++.exe&#8221; exited with code 1.<br />
那是少了依赖库引起的，比如说，如果你用到gles2，添加“ppapi_gles2”依赖库后，问题消失。<br />
Q 在“PPAPI”plaform下提示ppapi_cpp.obj找不到。<br />
修改依赖项从“ppapi_cpp;ppapi;”为“ppapi_cpp.lib;ppapi.lib;”后，重新rebuild即可。<br />
Q 运行“&#8230;\nacl_sdk\pepper_39\examples”下的例子,chrome提示“PnaclCoordinator: Compile process could not be created”</p>
<p>Chrome中输入“chrome://flags/”，停止“Native Client 基于 GDB 的调试 Mac, Windows, Linux, Chrome OS”项即可。</p>
<p>Q遇到sdk下的examples无法装载的例子</p>
<p>Chrome中输入“chrome://components”检查pnacI是否已经安装。</p>
<p><strong>总结</strong><br />
相对于NPAPI，PPAPI开发成本高，运行速度慢，所谓sandbox安全性只不过是始皇上缴天下铁器的强盗逻辑，<br />
唯一的亮点是PPAPI的pexe格式插件可以一处编译处处运行。</p>
<p><strong>备注：</strong><br />
[1]在“&#8230;\nacl_sdk\pepper_39\examples”路径下google提供了大量的example用来帮助开发者学习PPAPI。<br />
参考资料[10]也有大量的pexe例子。</p>
<h2><a style="color: #336699;" name="t6"></a>参考资料</h2>
<p>[1]《跨浏览器插件框架FireBreath安装与使用之一——Windows下的插件》</p>
<p>http://blog.csdn.net/ubuntu64fan/article/details/7941167</p>
<p>[2]《Firebreath插件制作》</p>
<p>http://blog.csdn.net/oldmtn/article/details/46362135</p>
<p>[3]FireBreath Home</p>
<p>http://www.firebreath.org/display/documentation/FireBreath+Home</p>
<p>[4]《firebreath 在谷歌和火狐浏览器下的调试 以及打包》</p>
<p>http://www.cnblogs.com/drzhong/p/firebreath_dubug.html</p>
<p>[5]《Building a firefox plugin – part one》</p>
<p>http://colonelpanic.net/2009/03/building-a-firefox-plugin-part-one/</p>
<p>[6]《Introduction to Portable Native Client》</p>
<p>https://www.chromium.org/nativeclient/pnacl/introduction-to-portable-native-client</p>
<p>[7]《Distributing Your Application》</p>
<p>https://developer.chrome.com/native-client/devguide/distributing</p>
<p>[8]《Problems when develop ppapi plugins in NACL.》</p>
<p>https://groups.google.com/forum/embed/#!topic/native-client-discuss/hihnZnB8k0M</p>
<p>[9]《2DPaintingModel》</p>
<p>https://code.google.com/p/ppapi/wiki/2DPaintingModel</p>
<p>[10]《ppapi example》</p>
<p>https://chromium.googlesource.com/chromium/src/ppapi/+/master/examples</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1435</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kindeditor 粘贴网络图片保存到服务器</title>
		<link>https://www.softwareace.cn/?p=1100</link>
		<comments>https://www.softwareace.cn/?p=1100#comments</comments>
		<pubDate>Thu, 08 Jan 2015 05:05:36 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>
		<category><![CDATA[kindeditor]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1100</guid>
		<description><![CDATA[人老了，记忆也衰退了。写代码时，只有思路，具体写起来确总忘这忘那。还有的特性或功能，脑子里朦胧记得曾经看到过或 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>人老了，记忆也衰退了。写代码时，只有思路，具体写起来确总忘这忘那。还有的特性或功能，脑子里朦胧记得曾经看到过或曾经写过却总也记不起来。在网 上找好多人的文章也就是转载别人，而图片因原作者空间失效而失效。于是想在自己blog 在转载好文章备份时，能顺便把里面图片也保存到自己服务器上。</p>
<p>由于对javascript 的了解不够深入，要在一个完全陌生的编辑器上做插件还真有点困难，加上php 也不是常用，边学边做发了三天终于将这样一个 粘贴网络图片保存到服务器 小插件做成功了。</p>
<p>贴出部分代码：</p><pre class="crayon-plain-tag">// 图片另存到服务器
		editor.addContextmenu({
	        title : '另存到服务器',
	        click : function() {
	         var img = getImageFromRange(editor.edit.cmd.range, function(img) {
	        	 	return !/^ke-\w+$/i.test(img[0].className);
	         	});
	         var imgsrc = img.attr('src');
	         K.ajax('./editor/php/saveToServer.php', function(data){var newsrc = K.formatUrl(data.url,'absolute');
	         editor.exec('insertimage', newsrc, '', '', '', '', '');
	         editor.hideMenu();} , 'POST' ,{imgurl:imgsrc});
	        },
	        cond : function() {
	        return getImageFromRange(editor.edit.cmd.range, function(img) {
	            return !/^ke-\w+$/i.test(img[0].className);
	        });
	        }
		});</pre><p>服务器端代码：</p><pre class="crayon-plain-tag">require_once 'JSON.php';
require_once '../../globals.php';
$php_path = ADMIN_ROOT . '/';
$php_url = dirname($_SERVER['PHP_SELF']) . '/../../';
$root_path = $php_path . OPTION::UPLOADFILE_PATH.'image/netimg/';
$root_url = $php_url . OPTION::UPLOADFILE_PATH.'image/netimg/';
set_time_limit(0);
$filepath=urldecode($_POST['imgurl']);
$imgArray=array('.gif','.jpg','.png','.jpeg','.bmp');
$typeArray=array();
ob_start();
$type=strrchr(trim($filepath),".");
$result = false;
if($filepath!='' &amp;&amp; in_array($type,$imgArray))
{
	$now=time();
	$filename=$now.strrchr(trim($filepath),".");
			//$filename=md5_file(trim($files[$i])).strrchr(trim($files[$i]),".");
	$ret = create_folders($root_path);
	if($ret != false){ 
		$savetime=SaveHTTPFile(trim($filepath),$root_path.$filename);
		$result = true;
	}
}
ob_end_flush();
if($result){
		header('Content-type: text/html; charset=UTF-8');
		$json = new Services_JSON();
		echo $json-&gt;encode(array('error' =&gt; 0, 'url' =&gt; $root_url.$filename));
		exit;		
}else{
		alert('创建目录失败！');
}

function getmicrotime(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}

function SaveHTTPFile($fFileHTTPPath,$fFileSavePath)
{
	//记录程序开始的时间
	$BeginTime=getmicrotime();

	//取得文件的内容
	ob_start();
	readfile($fFileHTTPPath);
	$img = ob_get_contents();
	ob_end_clean();
	//$size = strlen($img);

	//保存到本地
	$fp2=@fopen($fFileSavePath, "a");
	fwrite($fp2,$img);
	fclose($fp2);

	//记录程序运行结束的时间
	$EndTime=getmicrotime();

	//返回运行时间
	return($EndTime-$BeginTime);
}</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1100</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kindeditor编辑器高级篇：如何通过监听kindeditor编辑器的粘贴(CTRL+V)事件直接过滤掉复制内容内所有的标签包括超链接</title>
		<link>https://www.softwareace.cn/?p=1098</link>
		<comments>https://www.softwareace.cn/?p=1098#comments</comments>
		<pubDate>Wed, 07 Jan 2015 09:56:33 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>
		<category><![CDATA[kindeditor]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1098</guid>
		<description><![CDATA[昨天写个一篇如何在执行一键清除HTML功能键的同时去掉kindeditor编辑器内容的所有超链接的博客，地址为 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">昨天写个一篇如何在执行一键清除HTML功能键的同时去掉kindeditor编辑器内容的所有超链接的博客，地址为：</span><a style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #3570b3; text-decoration: none; background: transparent;" href="http://www.stepday.com/topic/?688" target="_blank"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">http://www.stepday.com/topic/?688</span></a><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;"> 今天琢磨了一下是否可以更加直接地在粘贴内容至kindeditor编辑器内的时候就清楚HTML标签和去掉所有的超链接，换句话说就是只能够粘贴纯文本进入kindeditor编辑器内。</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">通过翻看kindeditor-min.js源码文件，查找“<strong style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">b.pasteType === 1</strong>”关键词，我们看到的代码片段如下所示：</span></p>
<p></p><pre class="crayon-plain-tag">b.pasteType === 1 &amp;&amp; (d = d.replace(/&lt;br[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;\/p&gt;&lt;p[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;[^&gt;]+&gt;/g, ""), d = d.replace(/&amp;nbsp;/ig, " "), d = d.replace(/\n\s*\n/g, "\n"), d = d.replace(/ {2}/g, " &amp;nbsp;"), b.newlineTag == "p" ? /\n/.test(d) &amp;&amp; (d = d.replace(/^/, "&lt;p&gt;").replace(/$/, "&lt;/p&gt;").replace(/\n/g, "&lt;/p&gt;&lt;p&gt;")) : d = d.replace(/\n/g, "&lt;br /&gt;$&amp;")), b.insertHtml(d, !0))</pre><p>&nbsp;</p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">这段代码就是实现了CTRL+V的粘贴功能，获取粘贴板内的内容d，然后对其进行简单性的处理然后赋值给编辑器b。</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">在这里我们不难发现并未去除过多的HTML代码且清楚超链接，所以我们需要在这里对编辑器对象b做一些后加处理，我们通过b.text()就可以拿到编辑器内的纯文本内容了，然后再将其赋值给编辑器b不就行了么？</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">所以得到了修改后的代码片段：</span></p>
<p></p><pre class="crayon-plain-tag">b.pasteType === 1 &amp;&amp; (d = d.replace(/&lt;br[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;\/p&gt;&lt;p[^&gt;]*&gt;/ig, "\n"), d = d.replace(/&lt;[^&gt;]+&gt;/g, ""), d = d.replace(/&amp;nbsp;/ig, " "), d = d.replace(/\n\s*\n/g, "\n"), d = d.replace(/ {2}/g, " &amp;nbsp;"), b.newlineTag == "p" ? /\n/.test(d) &amp;&amp; (d = d.replace(/^/, "&lt;p&gt;").replace(/$/, "&lt;/p&gt;").replace(/\n/g, "&lt;/p&gt;&lt;p&gt;")) : d = d.replace(/\n/g, "&lt;br /&gt;$&amp;")), b.insertHtml(d, !0), b.html(b.text()))</pre><p><span style="color: #555555; font-family: '楷体 Std R'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 42px; orphans: auto; text-align: start; text-indent: 28px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">不难看出只是在最后的地方追加了</span></p>
<p><span style="color: #000000; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">b.html(b.text())</span></p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1098</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>kindeditor编辑器高级篇：如何做到一键清除HTML格式的同时去掉kindeditor编辑器内全部超链接(a)</title>
		<link>https://www.softwareace.cn/?p=1095</link>
		<comments>https://www.softwareace.cn/?p=1095#comments</comments>
		<pubDate>Wed, 07 Jan 2015 09:51:02 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[chrome]]></category>
		<category><![CDATA[kindeditor]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1095</guid>
		<description><![CDATA[在使用kindeditor编辑器的时候，大多数可能都是从某些网页直接粘贴内容复制到kindeditor编辑器内 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">在使用kindeditor编辑器的时候，大多数可能都是从某些网页直接粘贴内容复制到kindeditor编辑器内，这样可能内容就包含很多HTML标签和超链接。为了最快地进行内容编辑往往都使用kindeditor的“一键清除HTML”的功能，但是这个功能默认情况下是不会清除超链接的标签的。这一点往往令很多做编辑的人很是头疼，最后这个光荣的任务就落到了我们程序员的身上。</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">为了解决在清除HTML标签的同时也清除掉超链接，不得不研究了一番kindeditor的源码。最后将其问题的解决方案归咎到了一键清除HTML的对应</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">plugins/clearhtml/</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">clearHTML.js文件内。通过深入分析得出了这样两个解决方案：</span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;"><strong style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">1、修改formatHtml格式化方法</strong></span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">见</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">plugins/clearhtml/</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">clearHTML.js的formatHtml格式化方法如下所示：</span></p>
<p></p><pre class="crayon-plain-tag">html = K.formatHtml(html, {
			a : ['href', 'target'],
			embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
			img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
			table : ['border'],
			'td,th' : ['rowspan', 'colspan'],
			'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
});</pre><p>&nbsp;</p>
<div id="highlighter_372143" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
</div>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">从格式化方法不难看出它始终保持了a标签的href和target两个属性，所以问题的根本就在这里了的，解决方案就是去掉a标签的一切，修改后的代码如下所示：</span></p>
<p></p><pre class="crayon-plain-tag">html = K.formatHtml(html, {
			embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
			img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
			table : ['border'],
			'td,th' : ['rowspan', 'colspan'],
			'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
});</pre><p>&nbsp;</p>
<div id="highlighter_41853" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
<div class="lines" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"></div>
</div>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;"><strong style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">2、直接调用取消超链接的方法</strong></span></p>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">通过查找源码内的方法，可以直接调用去掉超链接的方法，同样修改</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">plugins/clearhtml/</span><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">clearHTML.js文件内，在</span></span></p>
<div id="highlighter_587187" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
<div class="lines" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">
<div class="line alt1" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"><code class="number" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0.3em 0px 0px; text-align: right; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 3em; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #5c5c5c; background: none;">1.</code><span class="content" style="border-width: 0px 0px 0px 3px; border-left-style: solid; border-left-color: #6ce26c; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px 0px 0px 3.3em; padding: 0px 0px 0px 0.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #000000; background: none #ffffff;"><span class="block" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0px 0px 1.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; text-indent: -1.5em; background: url('http://www.stepday.com/images/wrapping.png') 0px 1.1em no-repeat;"><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">self.addBookmark();</code></span></span></div>
</div>
</div>
<p style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #555555; font-family: '楷体 Std R'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 30px; orphans: auto; text-align: start; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-indent: 2em; background: #ffffff;"><span style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; line-height: 3; background: transparent;">后面追加一句语句：</span></p>
<div id="highlighter_432333" class="syntaxhighlighter " style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 1em 0px; padding: 1px; text-align: left; float: none; position: relative; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 950px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; color: #555555; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #e7e5dc;">
<div class="bar" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none;">
<div class="toolbar" style="border: 1px solid #e7e5dc; outline: 0px; font-size: 1px; vertical-align: baseline; margin: 0px; padding: 8px 8px 8px 0px; text-align: left; float: none; position: absolute; left: auto; top: 0px; right: 0px; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; background: none #f8f8f8;"><a class="item viewSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/page_white_code.png') no-repeat;" title="view source" href="http://www.stepday.com/topic/?688#viewSource">view source</a><a class="item printSource" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/printer.png') no-repeat;" title="print" href="http://www.stepday.com/topic/?688#printSource">print</a><a class="item about" style="border: 0px; outline: 0px; font-size: 12px; vertical-align: baseline; margin: 0px 0px 0px 8px; padding: 0px; color: #a0a0a0; text-decoration: none; text-align: left; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: 16px; width: 16px; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; overflow: hidden; text-indent: -5000px; background: url('http://www.stepday.com/images/help.png') no-repeat;" title="?" href="http://www.stepday.com/topic/?688#about">?</a></div>
</div>
<div class="lines" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;">
<div class="line alt1" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; background: transparent;"><code class="number" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0.3em 0px 0px; text-align: right; float: left; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: 3em; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #5c5c5c; background: none;">1.</code><span class="content" style="border-width: 0px 0px 0px 3px; border-left-style: solid; border-left-color: #6ce26c; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px 0px 0px 3.3em; padding: 0px 0px 0px 0.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; color: #000000; background: none #ffffff;"><span class="block" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px 0px 0px 1.5em; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; display: block; text-indent: -1.5em; background: url('http://www.stepday.com/images/wrapping.png') 0px 1.1em no-repeat;"><code class="keyword" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #006699; font-weight: normal; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-style: normal; background: none;"><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">self.exec(</code><code class="string" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: blue; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">'unlink'</code><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">,<span class="Apple-converted-space"> </span></code><code class="keyword" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #006699; font-weight: normal; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">null</code><code class="plain" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #000000; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">);<span class="Apple-converted-space"> </span></code><code class="comments" style="border: 0px; outline: 0px; font-size: 14px; vertical-align: baseline; margin: 0px; padding: 0px; color: #008200; text-align: left; float: none; position: static; left: auto; top: auto; right: auto; bottom: auto; height: auto; width: auto; line-height: normal; font-family: Consolas, Monaco, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-weight: normal; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: -21px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: none #ffffff;">//去掉编辑器内所有的超链接</code></code></span></span></div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1095</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>thunderbird 二次开发 xpcom 获取 pref 配置</title>
		<link>https://www.softwareace.cn/?p=1093</link>
		<comments>https://www.softwareace.cn/?p=1093#comments</comments>
		<pubDate>Tue, 06 Jan 2015 02:56:46 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[firefox 插件]]></category>
		<category><![CDATA[xul]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1093</guid>
		<description><![CDATA[[crayon-69fc1840aa9f6320623266/] &#160;]]></description>
				<content:encoded><![CDATA[<p></p><pre class="crayon-plain-tag">bool showProgress = false;
nsCOMPtr&lt;nsIPrefBranch&gt; prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch)
prefBranch-&gt;GetBoolPref("mailnews.show_send_progress", &amp;showProgress);</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1093</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>js ctypes  操作注册表</title>
		<link>https://www.softwareace.cn/?p=1047</link>
		<comments>https://www.softwareace.cn/?p=1047#comments</comments>
		<pubDate>Fri, 28 Nov 2014 11:19:47 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[firefox 插件]]></category>
		<category><![CDATA[xul]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=1047</guid>
		<description><![CDATA[[crayon-69fc1840aabb8273110740/] &#160;]]></description>
				<content:encoded><![CDATA[<p></p><pre class="crayon-plain-tag">function getLocalVersion(){
  //::RegSetValueExA(m_hkey, key.c_str(), 0, REG_SZ, (BYTE*)val.c_str(), (DWORD)val.size());
  //if (::RegOpenKeyExA(hkey, subKey.c_str(), 0, KEY_ALL_ACCESS, &amp;m_hkey) != ERROR_SUCCESS)
  var lib = ctypes.open("Advapi32.dll");
  var RegQueryValueExW = lib.declare("RegQueryValueExW", ctypes.winapi_abi, ctypes.int32_t, HKEY, ctypes.jschar.ptr, LPDWORD, LPDWORD, ctypes.jschar.ptr, LPDWORD);
  var RegOpenKeyExW = lib.declare("RegOpenKeyExW", ctypes.winapi_abi, ctypes.int32_t, HKEY, ctypes.jschar.ptr, LPDWORD, LPDWORD, HKEY.ptr);
  var m_hkey = HKEY();
  var version = ctypes.jschar.array(1024)("");;
  if (RegOpenKeyExW(HKEY(HKEY_LOCAL_MACHINE), ctypes.jschar.array()("SOFTWARE\\Wow6432Node\\xxx\\appname"),
    LPDWORD(0), LPDWORD(KEY_QUERY_VALUE), m_hkey.address()) == ERROR_SUCCESS)
  {
    var len = DWORD(1024 * 2);
    var ret = RegQueryValueExW(m_hkey,
      ctypes.jschar.array()("UpdateVersion"),
      LPDWORD(0),
      LPDWORD(0),
      version,
      len.address());
  }

  lib.close();
  var resutVersion = version.readString();
  return "["+resutVersion+"]";
}</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=1047</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用Visual Studio创建XPCOM组件</title>
		<link>https://www.softwareace.cn/?p=818</link>
		<comments>https://www.softwareace.cn/?p=818#comments</comments>
		<pubDate>Mon, 26 May 2014 01:47:03 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[npapi]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=818</guid>
		<description><![CDATA[一、开发环境设置 下载XULRunner和XULRunner SDK，当前版本是1.8.1.3。可以在http [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>一、开发环境设置<br />
下载<a href="http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/1.8.1.3/contrib/win32/xulrunner-1.8.1.3.en-US.win32.zip">XULRunner</a>和<a href="http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/1.8.1.3/contrib/sdk/xulrunner-1.8.1.3.en-US.win32.sdk.zip">XULRunner SDK</a>，当前版本是1.8.1.3。可以在<a href="http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/">http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/</a>找到最新的版本。</p>
<p>解压到一个目录下，我的目录结构：<br />
<img alt="" src="http://p.blog.csdn.net/images/p_blog_csdn_net/chinesejimmy/dir.PNG" /><br />
这个SDK里还需要两个dll文件，下载<a href="http://ftp.mozilla.org/pub/mozilla.org/mozilla/source/wintools.zip">wintools.zip</a>，从buildtools/windows/bin/x86里拷贝libIDL-0.6.dll、glib-1.2.dll到xulrunner/gecko-sdk/bin下。</p>
<p>二、XULRunner：Hello World!<br />
在xulrunner创建tests目录，如下：<br />
tests<br />
|&#8211;application.ini<br />
|&#8211;defaults<br />
|   |&#8211;preferences<br />
|   |   |&#8211;prefs.js<br />
|&#8211;chrome<br />
|   |&#8211;chrome.manifest<br />
|   |&#8211;HelloWorld<br />
|   |   |&#8211;test.xul</p>
<p>application.ini</p>
<div>
<pre class="crayon-plain-tag">[App]
Vendor=Duo
Name=tsetApp
Version=0.1
BuildID=20070530

[Gecko]
MinVersion=1.8
MaxVersion=1.8</pre>
</div>
<p>prefs.js:</p>
<div>
<pre class="crayon-plain-tag">pref("toolkit.defaultChromeURI", "chrome://tests/content/test.xul");</pre>
</div>
<p>chrome.manifest:</p>
<div>
<pre class="crayon-plain-tag">content tests HelloWorld/</pre>
</div>
<p>test.xul:</p>
<div><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />&nbsp;<br />
<pre class="crayon-plain-tag">&lt;?xml version="1.0"?&gt;
&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;

&lt;window id="controller-example" title="Hello World"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;

&lt;label value="Hello World!"/&gt;

&lt;/window&gt;</pre><br />
&nbsp;</p>
</div>
<p>在命令行下，进入xulrunner目录：</p>
<div><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />xulrunner.exe tests/application.ini</div>
<p>三、创建XPCOM组件<br />
参考：<a href="http://developer.mozilla.org/en/docs/How_to_build_a_binary_XPCOM_component_using_Visual_Studio">How to build a binary XPCOM component using Visual Studio</a><br />
VC++ Express Project：<a href="http://developer.mozilla.org/samples/xpcom/xpcom-test.zip">xpcom-test.zip</a><br />
主要有6步：</p>
<ul>
<li>把&#8221;xulrunner/gecko-sdk/include&#8221;加到Additional Include Directories里</li>
<li>把 &#8220;xulrunner/gecko-sdk/lib&#8221;加到Additional Library Directories里</li>
<li>添加&#8221;nspr4.lib xpcom.lib xpcomglue_s.lib&#8221;库</li>
<li>添加&#8221;XP_WIN;XP_WIN32″宏</li>
<li>不使用]预编译头</li>
<li>自定义XPCOM IDL编译步骤(右击*.idl文件，属性-&gt;自定义-&gt;命令行，输入$(ProjectDir)xpidl-build.bat $(InputFileName))</li>
</ul>
<p>四、测试XPCOM组件<br />
在上面建立的tests下创建components目录，把生成的.xpt、.dll文件拷贝到components。<br />
修改test.xul文件：（注意，要保存为uft-8编码。）</p>
<div>
<pre class="crayon-plain-tag">&lt;?xml version="1.0"?&gt;
&lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;

&lt;window id="controller-example" title="Controller Example"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;

&lt;script&gt;
function doXPCOM() {
    try {
        const cid = "@starkravingfinkle.org/specialthing;1";
        var obj = Components.classes[cid].createInstance();
        obj = obj.QueryInterface(Components.interfaces.ISpecialThing);
    }
    catch(err) {
        alert(err);
        return;
    }

    var res = obj.add(3, 4);
    alert('3+4 = ' + res);

    var name = obj.name;
    alert('Name = ' + name);

    obj.name = 'New Name';
    name = obj.name;
    alert('Name = ' + name);
}
&lt;/script&gt;

&lt;button id="testXPCOM" label="测试XPCOM" oncommand="doXPCOM();"/&gt;

&lt;/window&gt;</pre><br />
<img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" /></p>
</div>
<p>修改application.ini的BuildID，我改为20070601，运行这个程序就可以测试了。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=818</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mozilla plugin的MIME类型注册</title>
		<link>https://www.softwareace.cn/?p=177</link>
		<comments>https://www.softwareace.cn/?p=177#comments</comments>
		<pubDate>Tue, 19 Feb 2013 10:07:26 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[npapi]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=177</guid>
		<description><![CDATA[1.最简便的方法：修改npp_gate.cpp中的 [crayon-69fc1840ab08274447745 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>
	<span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">1.最简便的方法：修改npp_gate.cpp中的</span></p>
<p></p><pre class="crayon-plain-tag">char*
NPP_GetMIMEDescription(void)
{
return &amp;quot;application/mozilla-scriptable-plugin:.Suffixes:Description&amp;quot;;
}</pre><p></p>
<p>
	<span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">引号中的字段：MIME type：.扩展名：MIME type描述</span><br />
	<span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">2.如何在一个plugin中注册多个MIME type</span><br />
	<span style="color: #666666; font-family: 宋体, Arial; font-size: 12px; line-height: 26px; background-color: #ffffff;">格式是这样的：用&ldquo;；&rdquo;来分隔多个完整的MIME type描述（包括MIME type：.扩展名：MIME type描述），如果一个MIME type要支持多种扩展名则扩展名间用&ldquo;，&rdquo;做分隔符。</span></p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=177</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用NPAPI编写浏览器插件的调用本机上的程序</title>
		<link>https://www.softwareace.cn/?p=175</link>
		<comments>https://www.softwareace.cn/?p=175#comments</comments>
		<pubDate>Tue, 19 Feb 2013 06:18:48 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[npapi]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=175</guid>
		<description><![CDATA[from:csdn 使用NPAPI编写浏览器插件的源码实例 &#160; code:http://downlo [&#8230;]]]></description>
				<content:encoded><![CDATA[<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	from:csdn<br />
	使用NPAPI编写浏览器插件的源码实例</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	code:<a href="http://download.csdn.net/detail/echoisland/3878906" style="margin: 0px; padding: 0px; color: rgb(51, 102, 153); text-decoration: none; ">http://download.csdn.net/detail/echoisland/3878906</a></div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	用于种种原因,最近对制作浏览器(chrome,firefox)的插件非常感兴趣</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	搜了一下,讲的几乎全都是在讲的方法和API,找个简单可以运行的代码实例,还真是难!</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	不过最终还算幸运,终于找一个例子(http://geeklu.com/2010/10/getting-started-with-npapi-plugin/comment-page-1/).</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	很遗憾这个例子在我的linux机器上无法正常工作.所以我以此例子为基础写了个新例子,顺路我还写了个chrome的扩展作为演示.</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	关于NPAPI和chrome的扩展:</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	NPAPI:</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	[1] http://colonelpanic.net/2009/05/building-a-firefox-plugin-part-two/</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	[2] http://rintarou.dyndns.org/2010/04/23/scriptable-plugin-%E6%8E%A2%E8%A8%8E-20090408/</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	[3] http://blogold.chinaunix.net/u3/94039/showart_2004756.html</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	[4] https://developer.mozilla.org/en/Plugins</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	[5] 如何在chrome的扩展中使用:http://code.google.com/chrome/extensions/npapi.html</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	[6] 如何编写chrome的扩展:http://code.google.com/chrome/extensions/getstarted.html</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	插件的功能:</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	提供网页的javascript可以调用本机上的程序的能力,</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	所以本插件其实是很危险的,当然任何可以让网页调用本机上程序的插件都是很危险的.</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	不过这里只是一个演示插件编写的例子,看到的人不要惊慌哦&#8230;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	关于源码的说明</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	npapi/npapi.h</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	npapi/npfunctions.h</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	npapi/npruntime.h</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	npapi/nptypes.h</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	直接来自:http://code.google.com/p/npapi-headers/</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	plugin_exec.c中的一些函数:</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	char*</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	NP_GetMIMEDescription()</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	return的字符串的格式必须是:&quot;text/html:htm,html:HTML Document;application/x-texinfo:tex,texi,texinfo:TexInfo Document;&quot;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	详情请看[3]</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	NPError</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	NP_GetValue (void *future,</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;&nbsp; &nbsp; NPPVariable variable,</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;&nbsp; &nbsp; void *value)</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	一定要处理 variable为NPPVpluginNeedsXEmbed的case,否则chrome不会启用插件(firefox还算正常)</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	插件的演示方法:</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	$cp libplugin_exec.so ~/.mozilla/plugins</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	$firefox wkt.html&nbsp;</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	$google-chrome wkt.html ###在网页输入一个命令(必须运行后能跳出窗口,例如gnome-terminal,否则看不见效果),然后点&quot;Run&quot;按钮.</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
<div style="margin: 0px; padding: 0px; ">
		<img alt="使用NPAPI编写浏览器插件的源码实例 - wkt55555 - wkt的博客" src="http://img115.ph.126.net/ISCKJDw0PO8BGbVpLvFOxg==/2010857233622925916.png" style="margin: 0px 10px 0px 0px; padding: 0px; border: 0px none; max-width: 100%; " /></div>
<div style="margin: 0px; padding: 0px; ">
		<img alt="使用NPAPI编写浏览器插件的源码实例 - wkt55555 - wkt的博客" src="http://img.ph.126.net/VffoOfq6JsY50_gNhaWE0g==/1509268825123097266.jpg" style="margin: 0px 10px 0px 0px; padding: 0px; border: 0px none; max-width: 100%; " /></div>
<p>
		&nbsp;&nbsp;</p>
</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	chrome扩展的演示方法:</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	扩展在chrome_extension目录下</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	加载扩展(加载方法看[6]的第4步),</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	然后页面上每个link的右键菜单会多出一个菜单项&quot;save link to /tmp/link.log&quot;,</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	点击该菜单项后link的url就会被保存到/tmp/link.log</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
<div style="margin: 0px; padding: 0px; ">
		<img alt="使用NPAPI编写浏览器插件的源码实例 - wkt55555 - wkt的博客" src="http://img609.ph.126.net/jKYyDqLInnLpqberhKuc8w==/1901081992705962707.png" style="margin: 0px 10px 0px 0px; padding: 0px; border: 0px none; max-width: 100%; " /></div>
</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	本例源码地址:http://u.115.com/file/f23aeb448f</div>
<div style="margin: 0px; padding: 0px; font-size: 14px; line-height: 25px; color: rgb(102, 102, 102); font-family: Arial, Helvetica, simsun, u5b8bu4f53; background-color: rgb(250, 249, 247); ">
	注意此例仅在debian sid/ubuntu10.10 编译/测试.</div>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=175</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的Firefox插件开发之旅（8）——插件的安装与更新</title>
		<link>https://www.softwareace.cn/?p=152</link>
		<comments>https://www.softwareace.cn/?p=152#comments</comments>
		<pubDate>Wed, 30 Jan 2013 03:19:42 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[firefox 插件]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=152</guid>
		<description><![CDATA[插件写好了，下面就该做一个安装包了。最好再提供更新功能，以便在插件有更新的时候，及时通知用户进行插件更新。 我 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	插件写好了，下面就该做一个安装包了。最好再提供更新功能，以便在插件有更新的时候，及时通知用户进行插件更新。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	我们开发的时候，直接将生成的dll丢到Firefox安装目录下的plugins目录就可以工作了，但是你如何说服让用户来手动完成这件事情？估计很难。因此，提供一个安装包，可能是最好的选择。用户只需要点几下鼠标就可以完成插件的安装了。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	不过到写这篇文章的时候，我还不清楚怎么让安装包经过Mozilla的验证，因为没有经过验证的插件，在安装的时候会出现&ldquo;仅安装信任作者的附加组件&rdquo;提示对话框，提示用户仅安装受信任作者的插件。如果有人知道怎么去掉这个警告对话框，还望不吝赐教。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	最最简单的插件安装包在这篇文章中开头处写的很清楚了：<a href="https://developer.mozilla.org/en/Shipping_a_plugin_as_an_extension" style="color: rgb(0, 102, 170); text-decoration: initial;" title="https://developer.mozilla.org/en/Shipping_a_plugin_as_an_extension">https://developer.mozilla.org/en/Shipping_a_plugin_as_an_extension</a></p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	安装包的目录结构：</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	install.rdf<br />
	plugins/<br />
	&nbsp;&nbsp;&nbsp; pluginlib.dll<br />
	&nbsp;&nbsp;&nbsp; plugintypes.xpt</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	其中xpt文件可选。install.rdf的内容为：</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	&lt;RDF xmlns=&quot;<a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#%22" style="color: rgb(0, 102, 170); text-decoration: initial;">http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;</a>&nbsp;xmlns:em=&quot;<a href="http://www.mozilla.org/2004/em-rdf#%22" style="color: rgb(0, 102, 170); text-decoration: initial;">http://www.mozilla.org/2004/em-rdf#&quot;</a>&gt;<br />
	&nbsp; &lt;Description about=&quot;urn:mozilla:install-manifest&quot;&gt;<br />
	&nbsp;&nbsp;&nbsp; &lt;em:id&gt;mypluginid@myplugin.com&lt;/em:id&gt;<br />
	&nbsp;&nbsp;&nbsp; &lt;em:name&gt;My Plugin&lt;/em:name&gt;<br />
	&nbsp;&nbsp;&nbsp; &lt;em:version&gt;1.0&lt;/em:version&gt;<br />
	&nbsp;&nbsp;&nbsp; &lt;em:targetApplication&gt;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Description&gt;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;em:id&gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&lt;/em:id&gt;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;em:minVersion&gt;1.5&lt;/em:minVersion&gt;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;em:maxVersion&gt;3.0.*&lt;/em:maxVersion&gt;<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Description&gt;<br />
	&nbsp;&nbsp;&nbsp; &lt;/em:targetApplication&gt;<br />
	&nbsp; &lt;/Description&gt;<br />
	&lt;/RDF&gt;</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	将上面内容安装目录结构用zip格式压缩，将后缀名改为xpi就OK了。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	但是我们要做得事情远不止这些：</p>
<ul style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
<li>
		如何提供插件的更新自动通知？</li>
<li>
		如何将扩展和插件捆绑在一起让用户安装？（因为可能你不仅仅要安装插件，还希望在用户的FF工具栏或菜单上添加一些扩展功能）</li>
<li>
		如何对插件进行签名？</li>
<li>
		如何发布你的插件和扩展，以便让更多人知晓？</li>
</ul>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	要做的事情还很多。那么我们就一个个来研究吧。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	<strong>一、如何提供插件的更新自动通知？</strong></p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	关于Install manifest（即install.rdf）文件内容，Mozilla有篇很详细的文章：<a href="https://developer.mozilla.org/en/Install.rdf" style="color: rgb(0, 102, 170); text-decoration: initial;" title="https://developer.mozilla.org/en/Install.rdf">https://developer.mozilla.org/en/Install.rdf</a>，可以进行参考。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	其中有个节点名称是：updateURL。用这个标签包含一个可查询更新信息的URL连接，今后当FF在查询插件是否有更新时，会到你指定的这个URL上去查询。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	这个URL可以是一个cgi程序、servlet、asp(x)，也可以是一个固定的rdf文件链接。另外文章中也提到了另外一种办法：如果你没有提供updateURL，FF的附加组件管理器会向addons.mozilla.org发送请求，当你上传了一个新版本的插件或者通过作者接口（author interface）更改了兼容性参数，一个更新的manifest文件将会被自动产生。另外，Mozilla建议updateURL使用https而非http，否则你应该提供updateKey（可以用<a href="https://developer.mozilla.org/en/McCoy" style="color: rgb(0, 102, 170); text-decoration: initial;" target="_blank">McCoy</a>生成）。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	那么，负责更新的rdf怎么编写呢？你可以参考这篇文章：<a href="https://developer.mozilla.org/en/Extension_Versioning%2c_Update_and_Compatibility#Update_RDF_Format" style="color: rgb(0, 102, 170); text-decoration: initial;" title="https://developer.mozilla.org/en/Extension_Versioning%2c_Update_and_Compatibility#Update_RDF_Format">https://developer.mozilla.org/en/Extension_Versioning%2c_Update_and_Compatibility#Update_RDF_Format</a>。由于文章中写的很清晰，并且提供了详细的例子代码，这里我就不废话了。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	<strong>二、如何将扩展和插件捆绑在一起让用户安装？</strong></p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	这个很简单。之前的章节我们已经做过一个简单的Extension安装包，如果想附加一个插件的话，只需要和chrome的同级目录下新建一个plugins目录，然后将dll及相关文件放在里面，最后一起打包即可。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	当在FF中安装此xpi时，FF会将Extension和Plugin解压到FF的Profiles目录下。插件和扩展即可生效。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	注意这里与我们之前将插件dll放在FF安装目录下的plugins目录下有些不同（至少位置不同），FF同样能够正确地识别我们的插件。另外Mozilla也推荐做成安装包，这样，在用户卸载组件的时候，可以同时将Extension和Plugin都卸载掉。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	<strong>三、如何对插件进行签名？</strong></p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	很抱歉，还没找到答案&hellip;&hellip;</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	<strong>四、 如何发布你的插件和扩展，以便让更多人知晓？</strong></p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	首先需要在Mozilla网站上注册一个账号（需要提供合法E-mail，因为要激活）。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	登录后，在Mozilla 附加组件首页上你会看到一个&ldquo;开发者工具&rdquo;的链接。进入后，会有明显的导航链接，如&ldquo;提交附加组件&rdquo;。通过这个页面，按照向导，你就可以将你的插件发布出来了。剩下的事，就是宣传咯，呵呵。</p>
<p style="margin: 10px 0px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; background-color: rgb(255, 255, 255);">
	OK，《我的Firefox插件开发之旅》系列文章就先到这里。将来我也许还会写一些关于编写FF的Extension和Plugin方面的技术细节文章。看心情吧，呵呵。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=152</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
