Creating a Chrome extension that clicks all the "connect" buttons on the page and then clicks "next". Below is my code. I am unable to find the problem. I have put in some console.log()
s, but they don't appear to show up. Please ask any questions that might help debugging this problem.
html:
<!doctype html>
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<title>LinkedIn Connect</title>
<script src="popup.js"></script>
</head>
<body>
<h1>LinkedIn Connect</h1>
<button id="connectMe">Connect me now!</button>
</body>
</html>
mainfest.json:
{
"manifest_version": 2,
"name": "LinkedIn Connect",
"description": "This extension help with LinkedIn connections",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
]
}
popup.js:
document.addEventListener('DOMContentLoaded', function () {
console.log("1 clicked");
var connectMeButton = document.getElementById('connectMe');
connectMeButton.addEventListener('click', function () {
// Every 1 second, click all the connect buttons on the result page
console.log("2 clicked");
window.setInterval(function () {
$("a:contains('Connect')").each(function (
index, a) {
$(this).trigger('click');
});
//Scroll down to the button of the page
window.scrollTo(0, document.body.scrollHeight);
}, 1000);
//Click Next after every 5 seconds
window.setInterval(function () {
$("a:contains('Next >')")[0].click();
}, 5000);
}, false);
}, false);