I'm creating a simple chrome extension that basically detects if exists a script with the id of "x" is loaded in the page that the user is landed, if I call the id by jQuery works fine, but when i loaded in chrome extension popup.js it doesn't work, is there something wrong with my code?
Some landing page html:
<script data-cfasync="false" id="somename" type="text/javascript">...
Popup.js
document.addEventListener('DOMContentLoaded', function() {
console.log($('#clevernt').length);
if ($('#somename').length == 0) {
$('#title').html('Script does not exists.<br> <span class="dot-red"></span>');
}else{
$('#title').html('Script exists.<br> <span class="dot-green"></span>');
}
}, false);
Manifest.json:
{
"manifest_version": 2,
"name": "name",
"description": "This extension will check if clever script is loaded",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts":[
{
"matches":["<all_urls>"],
"js":["jquery.js"]
}
],
"permissions": [
"activeTab"
]
}