Hi there,
I hope you can help me with an issue I’m facing while developing a firefox extension.
Basically, my extension calls a javascript function from a certain page within my content script. This javascript function executes a http request to fetch data.
Sidenote: The content script can be started and stoped via a pop up html and js file.
I’ve tried to use the wrappedJSObject but get an error “Permission denied …” when calling window.wrappedJSObject.Primefaces.ab()
Calling a javascript function to change css for example words with the wrappedJSObject by the way.
I guess that It has to do with my manifest.json file, but I’m not sure as I’ve already tried different approaches.
My manifest.json:
{
"manifest_version": 2,
"name": "Menninger Freight Booking",
"version": "1.0",
"description": "Manages automatic booking of freight offers.",
"icons": {
"48": "icons/38.png"
},
"permissions": [
"activeTab",
"storage",
"webRequest",
"webNavigation",
"*://*.localhost/*",
"*://jsonplaceholder.typicode.com/*"
],
"content_scripts": [
{
"matches": ["*://*.localhost/*", "*://my.timocom.com/app/tco/freight/search/*", "*://jsonplaceholder.typicode.com/*"],
"js": ["js/jquery-3.3.1.min.js", "js/contentscript.js"]
}
],
"browser_action": {
"default_icon": {
"19": "icons/19.png",
"38": "icons/38.png"
},
"default_title": "Menninger",
"default_popup": "popup/choose_settings.html"
}
}
My content script as follows:
(function () {
if (window.hasRun) {
return;
}
window.hasRun = true;
browser.runtime.onMessage.addListener((message) => {
if (message.command === "startBooking") {
/**
* Some other code here
*/
try {
// ab() function executes an xhr request
window.wrappedJSObject.PrimeFaces.ab({
source:'app:cnt:ricosForm:remoteCmdSelectRow',
formId: 'app:cnt:ricosForm',
process: '@none',
update:'app:cnt:searchDetail:messages',
oncomplete: function(xhr, status, args) {
console.log("STATUS", status, xhr, args);
},
params: [{name: "selectedrownum", value: 2}]
});
}
catch (e){
// Permission denied error is raised here!
console.error("An error occurred while executing PrimeFaces.ab() for retrieving detail page with error", e);
}
}
else if (message.command === "stopBooking") {
console.log("Received stop booking command");
/**
* Do sth else here
*/
}
});
})();
Could you please advice me how to handle this problem?
Best Regards,
Carl