0
根據MDN的頁面page-worker API,我應該能夠使用Reg-ex作爲我函數的include部分的參數。FireFox addon-sdk page-worker正則表達式
var data = require("sdk/self").data;
var page = require("sdk/page-worker");
var re = new RegExp("/.*google.*/");
function doTheThing(){
page.Page({
include: re,
contentURL: data.url("webPage.html"),
contentScriptWhen: "ready",
contentScript: 'document.body.style.border = "5px solid red";'
})
}
這段代碼的作用是,當一個標籤加載在瀏覽器中,它應該檢查URL,如果它具有谷歌作爲它的一部分,我應該ContentScript運行。問題是,我碰到下面的錯誤..
Message: RequirementError: The option "include" must be one of the following types: string, array, undefined
我爲什麼不能使用REG-EX作爲我的論點?該API明確指出Reg-ex是允許的。
優秀。非常感謝,這解決了它。 – Shadowvail 2015-03-03 14:28:36