in src/js/other-websites/inpage_menu.js [746:791]
generateMaskButton: async () => {
// Create "Generate Relay Address" button
const generateAliasBtn = document.querySelector(
".fx-relay-menu-generate-alias-btn"
);
generateAliasBtn.textContent = browser.i18n.getMessage(
"pageInputIconGenerateNewAlias_mask"
);
// Handle "Generate New Alias" clicks
generateAliasBtn.addEventListener("click", async (generateClickEvt) => {
sendInPageEvent("click", "input-menu-reuse-previous-alias");
preventDefaultBehavior(generateClickEvt);
generateAliasBtn.classList.add("is-loading");
// Request the active tab from the background script and parse the `document.location.hostname`
const currentPageHostName = await browser.runtime.sendMessage({
method: "getCurrentPageHostname",
});
// Attempt to create a new alias
const newRelayAddressResponse = await browser.runtime.sendMessage({
method: "makeRelayAddress",
description: currentPageHostName,
});
// Catch edge cases where the "Generate New Alias" button is still enabled,
// but the user has already reached the max number of aliases.
if (newRelayAddressResponse.status === 402) {
generateClickEvt.target.classList.remove("is-loading");
throw new Error(
browser.i18n.getMessage("pageInputIconMaxAliasesError_mask")
);
}
browser.runtime.sendMessage({
method: "fillInputWithAlias",
message: {
filter: "fillInputWithAlias",
newRelayAddressResponse,
},
});
});
},