【Chrome Extension】選択されているタブIDを取得する
popup.html
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Nico Extension's Popup</title> <style> body { min-width: 100px; } </style> </head> <body> <ul> <li id = "tab">tab</li> </ul> <script src="src/index.js"></script> </body> </html>
index.js
document.getElementById('tab').onclick = function() { chrome.tabs.getSelected(window.id, function(tab){ alert(tab.id); }) }
右クリック > 「要素を検証」でコンソールを出しておいてください。