Firefox Extension util/match
I'm developing a browser extension for both Mozilla Firefox and Google Chrome. The extension provides functionality for Oracle APEX. Since is is supposed to run only on pages running Oracle APEX, I identify such pages with matching patterns in the subdirectory and parameters. This is easy for Chrome where I add this to my manifest.json
"content_scripts": [{
"matches": ["*://*/*f?p=*", "*://*/*wwv_flow.accept*"],
"js": ["content_script.js"],
"run_at": "document_end"
}]
But if I try the same in Firefox with the PageMod API in the main.js I can't get any matches and I try various combinations:
main.js
pageMod.PageMod({
include: ["*://*/*f?p=*", "*://*/*wwv_flow.accept*"],
contentScriptFile: data.url("content_script.js"),
contentScriptWhen: "end",
Right now I'm running the content_script in Firefox on any Page and check the URL using the Javascript match functionality, if there is not match I return immediately
content_script.js
var url = unsafeWindow.location.href;
if (url.match(new RegExp("f?p=")) || url.match(new RegExp("wwv_flow.accept")))
My question is, if it is possible to get a matching pattern for the PageMOD API or if there is any other solution so my content script won't run on any page?
The match pattern supports regex so something like this should work. You might have to play around with the exact syntax a little.
["/.*f?p=.*/*", "/.*wwv_flow.accept.*/"]
上一篇: 我们如何检查这是否为内容脚本?