Skip to content

listen in content-script and change some elements in Dom #8

@husin-sajjadi

Description

@husin-sajjadi

Thank you for your sample!
I have a problem with development chrome extension,
Let me explain that:
I have a popup.js and popup.html
also I have a content.js as a content-script
also I have a background.js as a background script

Now, I want to click on a button in popup.js and then listen it in content-script and change some elements in dom.

But I don't receive any data in content script

popup.js
chrome.tabs.query({active: true, currentWindow: true}, async (tabs) => { chrome.tabs.sendMessage(tabs[0].id, {message: 'changeDOM'}); });

content.js
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { console.log("request"); });

How can I solve it?
Should I use a background service?

Thank you for your response!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions