I am new to chrome extension. And I need to create an extension That Appends the external class to the selected tag.
ex:- page
<h1>extension</h1> need to add an external class to the DOM when this tag mouse is clicked on the element. (should not be an empty element)
For that, I am creating a chrome extension. In order to do this, I need to have a fixed popup or Canvas. Like the CSS Selector use.
I want my popup.html to close only when I click on the close button, not when I click on the element of the page. I can not find a way to stick the popup. it is closed every time I clicked on the web page.
this is my manifest code
{
"manifest_version": 2,
"name":"Spider_Extension",
"version":"1.0",
"permissions": [
"tabs"
],
"content_scripts":[{
"matches":[
"<all_urls>"
],
"js":["Content.js"]
}],
"background": {
"scripts": ["background.js"]
},
"browser_action":{
"default_icon":"get_started16.png"
}
}
this is my background.js
function button_clicked(tab){
let msg={
txt:"hello"
}
console.log(tab)
chrome.tabs.sendMessage(tab.id,msg);
}
this is my popup.html
<html>
<head>
<title>Spider extension</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<label for="cars">Select Level:</label>
<select id="levels">
<option value="l1">L1</option>
<option value="l2">L2</option>
<option value="l3">L3</option>
<option value="l4">L4</option>
</select>
<br>
<button id="addLevel" style="margin:5px;">Add level</button>
<br>
<button id="break" style="margin:5px;">Break</button>
<br>
<button id="deselect" style="margin:5px;">Deselect</button>
<br>
<button id="nd__close">X</button>
<script src="popup.js"></script>
</body>
</html>
can anyone guide me for a solution ?
thank you in advance
