I know on stackoverflow there are many solutions but still I failed, I cannot do it. I want to print hello world in main page console from extension. How can I do it? I will share what I did until now.
(As you see in the picture, there is nothing on the main console.)
html of extension:
<!DOCTYPE html>
<html>
<head>
<title>Saitama Techno</title>
</head>
<body>
<h1>Welcome to Saitama Techno</h1>
<button id="mybutton">Click me</button>
<script src="myscript.js"></script>
</body>
</html>
javascript code:
function btnclicked(){
console.log("Hello from extension");
chrome.extension.getBackgroundPage().console.log('hello to main console');
}
document.getElementById("mybutton").addEventListener("click", btnclicked);
manifest.json:
{
"name": "Saitama Techno scraping",
"version": "1.0.0",
"description": "webscraping duuuuuuude",
"manifest_version": 3,
"author": "Enes Telli",
"action": {
"default_popup": "index.html",
"default_title": "Saitama Techno"
},
"permissions": ["https://*/*",
"http://*/*", "storage", "tabs", "declarativeContent", "activeTab", "scripting"]
}