I am trying to make an Add-on to help simplify daily things I do at work. I have already made the addon and it works fine, but I’m trying to improve it but I’ve run into issues. The addon’s popup window scrapes data from our ticketing system, then shows the data that it found and has a print button. That print button opens a new window and prompts to print, then closes automatically. I am printing a receipt with data pertaining to the user, their computer, and location. For certain tickets, I want to hide/remove certain fields, but for other tickets keep those fields. I already have it set up to always show the fields whether there is data there or not, but for this one specific ticket type I want those fields to be hidden. Right now, the version of this addon for Chromium browsers works fine and does what I want it to, but when I try to set it up for Firefox, it does not detect the ticket’s item type. Even manually setting the variables to true does not hide the fields. Am I putting the logic for this in the wrong file? Or is it not being injected properly? Or is it something else?
The popup.js calls content.js, then when I print, it calls print.js and print.html.
https://addons.mozilla.org/en-US/firefox/addon/otdi-device-receipt/
A) Your extension uses MV3, but in popup.js there’s:
async function injectContentScript(tabId, file) {
if (api.scripting && api.scripting.executeScript) {
// Chrome MV3
return api.scripting.executeScript({
target: { tabId, allFrames: true },
files: [file]
});
} else if (api.tabs && api.tabs.executeScript) {
// Firefox
return api.tabs.executeScript(tabId, {
file: file,
allFrames: true
});
} else {
console.error(“No supported script injection method found.”);
}
}
browser.tabs.executeScript is only available in MV2, according to tabs.executeScript() - Mozilla | MDN
(Note at the beginning and Browser compatibility table at the end.
B) manifest.json has a “content_scripts” key, meaning it loads content.js automatically into https://osuitsm.service-now.com/*
But the extension also injects content.js into the current tab when the user opens the popup.
Can you check if content.js gets injected twice?
C) When I go to about:debugging#/runtime/this-firefox and install the extension with “Load Temporary Add-on…”, Firefox shows these warnings:
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_personal_data: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_user_activity: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_health_data: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_financial_data: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_location_data: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_web_history: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_communications: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_identifiers: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_authentication_info: An unexpected property was found in the WebExtension manifest.
Reading manifest: Warning processing browser_specific_settings.gecko.data_collection_permissions.collects_contacts: An unexpected property was found in the WebExtension manifest.
Firefox built-in consent for data collection and transmission | Firefox Extension Workshop doesn’t mention any “browser_specific_settings.gecko.data_collection_permissions.collects_*” keys.
If you used an AI to generate manifest.json: Please don’t do that
Read the documentation, even if it takes more time.