Hello
I created code that should hide element in my browser, but it doesn’t work
browser.runtime.onMessage.addListener(function(message) {
if (message.action === ‘hideFormRow’) {
const formRows = document.querySelectorAll(’.form-row’);
formRows.forEach(formRow => {
const span = formRow.querySelector(’.label-text’);
if (span && span.textContent.includes(‘myText’)) {
formRow.style.display = ‘none’;
}
});
}
});
You wrote that “it doesn’t work”.
That doesn’t tell us very much. If you want help, you need to give us more information.
a) Edit your question and add the code of all files in your extension. Start with manifest.json
b) Give us the URL of a website where you want to use the extension, so that we can see for ourselves what doesn’t work any why.
c) Please read Debugging and then tell us if there are any error messages.
Change the title of your thread to something more informative, maybe:
Extension doesn’t hide element on webpage
Move your post to “Addons Development” when you edit it.
(But I’m not sure if you can do this as a new forum member)