After some research I found this question which is about a similar situation.
For this issue, an example would look like this (adapted from linked question):
popup.js (linked in your popup):
document.getElementById('yourButton').addEventListener('click', function() {
chrome.tabs.query({active: true, currentWindow: true}, function(activeTabs) {
chrome.tabs.sendMessage(activeTabs[0].id, { action: 'injectCSS' });
});
});
then you could include an content.js
into every (or your preferred) site via your application's manifest file:
"content_scripts": [
{
"matches": ["https://airbnb.com/*"], //or "matches": ["<all_urls>"]
"js": ["js/content.js"]
}
]
content.js:
chrome.runtime.onMessage.addListener(function(request) {
if (request.action === 'injectCSS') {
var css = document.createElement('style');
css.innerHTML = 'div:hover { outline: 1px solid blue; }';
document.head.appendChild(css);
}
});
Explanation:
popup.js listens for the onClick
event of the button ID #yourButton
in your popup. If triggered, a message event is piped to the currently selected tab and handled by content.js, wich is linked into the site by your extension's manifest. This script then creates a new <style>
element, pastes the CSS into it and appends it to the <head>
section of the DOM.
I hope I could help!