簡體   English   中英

將Firefox附加組件轉換為便簽本格式

[英]Converting a Firefox add-on to scratchpad format

在以下情況下,在暫存器中調試Firefox加載項會返回一些錯誤:

  1. 使用要求
  2. 定義一些GUI,例如圖標,按鈕等。
  3. 與其他頁面進行交互(即內容腳本)
  4. (可能還有其他情況)

考慮以下Get Cursor Position示例:

Components.utils.import("resource://gre/modules/ctypes.jsm");
var lib = ctypes.open("user32.dll");

/* note: if you go to GetCursorPos page on MSDN, it says first argument is of structure POINT, so lets create that structure,
 * the link here shows that that x and y are type Long which is ctypes.long
 */
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd162805%28v=vs.85%29.aspx
var POINT = new ctypes.StructType("tagPOINT", [
  { "x": ctypes.long },
  { "y": ctypes.long }
]);

/* Declare the signature of the function we are going to call */
var GetCursorPos = lib.declare('GetCursorPos',
    ctypes.winapi_abi,
    ctypes.bool,
    POINT.ptr
);

/* Use it like this */
var point = POINT();
var ret = GetCursorPos(point.address());

Components.utils.reportError(ret);
Components.utils.reportError(point);

lib.close();

我們希望通過更好的示例或其他方式幫助您編輯和完成問題。

對於SDK插件,我建議您改用jpm watchpost + extension自動安裝程序

每次保存文件時,這將自動創建一個xpi並將其重新安裝在瀏覽器中。 只需保持瀏覽器控制台處於打開狀態,您將獲得任何潛在的錯誤輸出。

與其他頁面進行交互(即內容腳本)

瀏覽器工具箱的暫存器可以選擇執行它的目標環境

使用要求

在chrome上下文中,可以通過let { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js")

如果您使用插件調試器,我認為插件的要求應該可用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM