console.log() doesn’t work in a developing chrome extension.

Summary

I show how to check the outclick of console.log() on developing chrome extension.

Show my codes

# manifest.json
{
  "name": "MyTestExtension",
  "manifest_version": 2,
  "version": "1.0",
  "browser_action": {
    "default_popup": "popup.html"
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["jquery-3.4.1.min.js", "re_download.js"]
    }
  ]
}
# popup.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <script type="text/javascript" src="jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="my_jsfile.js"></script>
  </head>
  <body>
    <button id="test">test button</button>
  </body>
</html>
# my_jsfile.js
$(function() {
  $("#test").click(function() {
    console.log("hello");
  });
});

What happen ?

I uploaded the developing chrome extension.
I opend develper tools and saw console.
And click the ‘test button’ but nothing appered in the console.

How to soleve the probrem

At first, click the icon of the extension to show ‘test button’.
Right click on the ‘test button’ and click the validation button.
So new develper tools is appered in the new window.
See the console panel of new window, and click ‘test button’.
“hello” will be shown!

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です