FF插件开发——GridSystem

本文详细介绍了将helloworld更名至gridSystem的过程,包括插件ID更改、目录结构调整、DOM和CSS的插入与动态设置、菜单栏与工具栏的集成,以及如何在菜单栏和帮助模块中显示插件。此外,还分享了自定义尺寸弹出框的代码实现和popup.xul文件的写法。最后,探讨了引入外部CSS文件的问题以及popup.js的调用方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 由helloworld改名为gridSystem的注意点:

①install.rdf的插件ID改为:gridSystem@mozilla.doslash.org。同时,调试目录下%APPDATA%\Mozilla\Firefox\Profiles下的gridSystem@mozilla.doslash.org文件相应的改名。

②相应的目录结构发生变化,overlay.xul中需要改写两处路径。chrome.manifest下要改写5处路径。至于overlay.xul中的overlay id不改也没什么关系。


2. 向页面中写入DOM和CSS。

①向头部加入CSS,加入了但不生效

var styleElement = document.createElement("style");
styleElement.setAttribute("type","text/css");
var message = "#E-GS{position:absolute;top:0;left:0;width:200px;height:200px;background-color:red;}";
var styleNode = document.createTextNode(message);
styleElement.appendChild(styleNode);
doc.head.appendChild(styleElement);

        ②在DOM前加入css,加入了但不生效

doc.body.appendChild(styleElement);

③插入到原页面的CSS文件中,OK

④只好直接写到标签里了。

3. 对插入的DOM div 动态设置高度。

4.寻找合适的覆盖点插入我的组件:

<menubar id="main-menubar">
    <menu id="alexa-relatedlinks1" label="hello" persist="hidden" accesskey="r">
      <menupopup id="alexa-relatedlinks-menu"
                 onpopupshowing=""
                 />
    </menu>
  </menubar>

插入菜单栏,与文件平级,在帮助的后面。

<toolbarpalette id="BrowserToolbarPalette">
        <toolbarbutton id="GridSystem-button" class="chromeclass-toolbar-additional toolbarbutton-1" label="GridSystem" tooltiptext="GridSystem" oncommand=""/>
        <toolbarbutton id="GridSystem-disable-toolbar" label="显示栅格" tooltiptext="显示栅格" type="menu" onmouseover="">
            <menupopup onpopupshowing="webdeveloper_updateDisableMenu('toolbar')">
                <menuitem id="GridSystem-disable-cache-toolbar" accesskey="" label="javascript" type="checkbox" oncommand=""/>
	    </menupopup>
	 </toolbarbutton>
  </toolbarpalette>

这个是像web developer一样订到工具栏面板上的。没有具体了解。暂时这样。


5. 把插件显示在菜单栏帮助的后面

  <menubar id="main-menubar">  //id不能改变
    <menu id="myextension" label="我的插件" persist="hidden" accesskey="r">  
      <menupopup id="menu_ToolsPopup">
	    <menu id="GridSystem" accesskey="" 
		class="menuitem-iconic" image="chrome://webdeveloper/skin/toolbar/disable.png" label="显示栅格">
			
	    </menu>
      </menupopup>
    </menu>  
  </menubar> 


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

终于把栅格系统做完了,所做总结如下:

1. 自定义尺寸时的弹出框代码:

window.openDialog("chrome://GridSystem/content/popup.xul", "", "centerscreen,chrome,modal");

不需要计算弹出框的大小和如何居中显示


2.overlay.xul的代码如下:

<menubar id="main-menubar">  
    <menu id="myextension" label="我的插件" persist="hidden">  
      <menupopup id="menu_ToolsPopup">
	    <menu id="GridSystem" 
		class="menuitem-iconic" image="chrome://webdeveloper/skin/toolbar/disable.png" label="显示栅格">
			<menupopup id="menu_ToolsPopup">
				<menuitem id="GridSystem-type1" label="50*20" oncommand="GridSystem.onMenuItemCommand(event,{columnWidth:50,gutterWidth:20});"/>
				<menuitem id="GridSystem-type2" label="60*30" oncommand="GridSystem.onMenuItemCommand(event,{columnWidth:60,gutterWidth:30});"/>
				<menuitem id="GridSystem-type3" label="自定义" oncommand="GridSystem.onMenuItemCommand(event);"/>
			</menupopup>
	    </menu>
      </menupopup>
    </menu>  
  </menubar> 

同时包含一级菜单和二级菜单


3. popup.xul的写法值得借鉴一下:

<dialog buttons="accept, cancel"
        id="webdeveloper-resize-dialog"
        ondialogaccept="GridSystem_saveResize()"
        ondialogcancel=""
        onload="webdeveloper_initializeResize()"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
	
	<script type="application/x-javascript" src="chrome://GridSystem/content/popup.js"/>

<vbox>
        <grid>
            <columns>
                <column/>
                <column/>
            </columns>
            <rows>
                <row align="center">
                    <label control="GridSystem.resize.width" value="列宽度"/>
                    <hbox>
                        <textbox id="GridSystem.resize.width" size="4"/>
                        <spacer flex="1"/>
                    </hbox>
                </row>
                <row align="center">
                    <label control="GridSystem.resize.height" value="渠宽度"/>
                    <hbox>
                        <textbox id="GridSystem.resize.height" size="4"/>
                        <spacer flex="1"/>
                    </hbox>
                </row>
            </rows>
        </grid>
    </vbox>

</dialog>

默认accept、cancel为确定、取消按钮。取消事件不需要额外添加。

引入新的popup.js,路径为全路径

注意表格布局

4. popup.js

function GridSystem_saveResize(){
	var columnWidth = document.getElementById("GridSystem.resize.width").value;
	var gutterWidth = document.getElementById("GridSystem.resize.height").value;
	window.opener.GridSystem.onMenuItemCommand(null,{columnWidth:columnWidth,gutterWidth:gutterWidth});
}

可囍的是popup.js中可以通过window.opener.GridSystem来调用其方法。

5. 遗憾的是,无法引入外部css文件,skin/overlay.css还未被使用。

内容概要:本文深入解析了扣子COZE AI编程及其详细应用代码案例,旨在帮助读者理解新一代低门槛智能体开发范式。文章从五个维度展开:关键概念、核心技巧、典型应用场景、详细代码案例分析以及未来发展趋势。首先介绍了扣子COZE的核心概念,如Bot、Workflow、Plugin、Memory和Knowledge。接着分享了意图识别、函数调用链、动态Prompt、渐进式发布及监控可观测等核心技巧。然后列举了企业内部智能客服、电商导购助手、教育领域AI助教和金融行业合规质检等应用场景。最后,通过构建“会议纪要智能助手”的详细代码案例,展示了从需求描述、技术方案、Workflow节点拆解到调试与上线的全过程,并展望了多智能体协作、本地私有部署、Agent2Agent协议、边缘计算插件和实时RAG等未来发展方向。; 适合人群:对AI编程感兴趣的开发者,尤其是希望快速落地AI产品的技术人员。; 使用场景及目标:①学习如何使用扣子COZE构建生产级智能体;②掌握智能体实例、自动化流程、扩展能力和知识库的使用方法;③通过实际案例理解如何实现会议纪要智能助手的功能,包括触发器设置、下载节点、LLM节点Prompt设计、Code节点处理和邮件节点配置。; 阅读建议:本文不仅提供了理论知识,还包含了详细的代码案例,建议读者结合实际业务需求进行实践,逐步掌握扣子COZE的各项功能,并关注其未来的发展趋势。
### 如何开发 Final Fantasy Plugin (FFPlug) #### 创建插件的基础结构 为了创建名为 `Final Fantasy Plugin` 的 WordPress 插件,可以遵循标准的 WordPress 插件开发流程。以下是具体实现方法: 1. **建立插件目录** 需要在 `wp-content/plugins/` 目录下新建一个文件夹,命名为 `final-fantasy-plugin`[^1]。 2. **创建主 PHP 文件** 在新创建的 `final-fantasy-plugin` 文件夹中新增一个 PHP 文件,例如命名为 `final-fantasy-plugin.php`。 3. **编写基础头部信息** 将以下代码复制并粘贴至 `final-fantasy-plugin.php` 中作为插件的基本元数据定义: ```php <?php /** * Plugin Name: Final Fantasy Plugin * Plugin URI: https://example.com/final-fantasy-plugin/ * Description: A plugin inspired by the world of Final Fantasy. * Version: 1.0.0 * Requires at least: 5.9 * Requires PHP: 7.4 * Author: Your Name Here * Author URI: https://yourwebsite.com/ * License: GPL v2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html */ ``` 此部分提供了关于插件的关键描述信息,使得它可以在 WordPress 后台管理界面被识别和启用。 #### 添加功能逻辑 一旦基本框架搭建完成,可以通过向该 PHP 文件添加更多自定义函数来扩展其功能性。例如,如果希望此插件能够显示一条消息,则可加入如下代码片段: ```php function display_final_fantasy_message() { echo '<p>Welcome to the magical realm of Final Fantasy!</p>'; } add_action('admin_notices', 'display_final_fantasy_message'); ``` 上述代码通过挂载到 `admin_notices` 动作钩子上,在后台仪表盘页面展示一段欢迎文字。 #### 测试与调试 在本地环境中测试插件的功能是否正常运行非常重要。激活插件之后观察是否有预期效果呈现出来,并利用浏览器开发者工具排查可能存在的 JavaScript 错误或者服务器端日志记录分析潜在问题所在之处。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值