I am trying to create a chrome extension that will automatically click on button 4 times in every hour on a specified webpage when you click on extension, but for some reason it does nothing to find button and click.
- auto click on given extension directs to URL www.ighoot.com
- auto click login button
- auto click again second login waits or load 5sec
- auto click on autofollow button
- auto click on getfollow button
- repeat above steps in every 60min
How to access and autoclick the button by using its Xpath.
manifest.json
{
"manifest_version": 2,
"name": "AutoFollow",
"description": "This allows the extension to auto click link and button in every hour",
"version": "1.0",
"browser_action": {
"default_icon": {"38": "auto.png"}
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"permissions": ["activeTab","tabs"]
}
background.js
chrome.tabs.create
chrome.browserAction.onClicked.addListener(function(tab) {
var newURL = "http://ighoot.com";
chrome.tabs.create({ url: newURL });
chrome.tabs.executeScript({file: "content.js"});
});
content.js
if (interval) {
clearInterval(interval);
interval = 0;
} else {
var btn = document.querySelector("#slogin");
if (btn) {
var interval = setInterval(function() {
btn.click();
}, 60 * 1000);
}
}
function myFunc() {
document.getElementById('hello').click();
};
setInterval(myFunc, 3000);