Firefox Add-on SDK content script include

做個小筆記。

像是這樣:

pageMod.PageMod({
include: /https?:\/\/www\.example\.com\/.+\/?$/,
contentScriptFile: [data.url("jquery-1.8.3.min.js"), data.url("read_aha.js")],
onAttach: function (worker) {
worker.port.on("testing", function (m) {
console.log(m);
});
}
});

什麼時候會 include 這個 content script 呢?實驗發現

  • 當分頁 URL 符合這個 regex 的時候
  • 以下這些不會:
    • <link href="xxx.css">
    • XMLHttpRequest
  • 但是 <iframe> 會!

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s