chrome.tabs.query({url: "*://xxxxxxxxxx.com/*"}, function reloadb() { window.document.querySelectorAll('.dropdown-item')[5].click(); // BUTTON NEWEST }); setInterval(reloadb, 5000); Why doesn't the code work? If you remove chrome.tabs.query({url: "*://xxxxxxxxxx.com/*"}, then the code will work, but I need this part of the code to be executed on a specific site. The extension reloads the page if it finds the right link sends the search form to another site. Therefore, the code for each site must be different. Just in case I will post the contents of the manifest file
{ "manifest_version": 2, "name": "BountySkins", "version": "0.1", "permissions": ["tabs"], "background": { "scripts": ["background.js"] }, "content_scripts": [ { "matches": [ "*://xxxxxxxxxx.com/*", "*://aaaaaaaaaa.net/*" ], "js": ["jquery-3.2.1.min.js", "content.js"] } ], "browser_action": { "default_icon": "icon.png" } }