I'd like to develop a Chrome extension that allows me to accept automatically all the connection requests on Linkledin, without any button, just by installing the extension.
My content.js is like this
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.action === "addInvitations") {
console.log("message?");
addInvitations();
}
});
function addInvitations() {
console.log("la vie est belle");
var connections = document.querySelectorAll('.invitation-card__action-btn.artdeco-button--secondary');
for (var i = 0; i < connections.length; i++) {
//connections[i].click();
console.log("hep hep hep");
console.log(connections[i]);
}
}
and my background.js is like this :
chrome.runtime.onInstalled.addListener(function() {
console.log("back ?");
chrome.tabs.query({ url: "https://www.linkedin.com/mynetwork/invitation-manager/" }, function(tabs) {
for (var i = 0; i < tabs.length; i++) {
chrome.tabs.sendMessage(tabs[i].id, { action: "addInvitations" });
}
});
});
But it does nothing !
On DevTools, there is no message beside the 4 console.log() i've put on the code. And on DevTools > Sources, there is no content.js when i'm on the right page.
My manifest is like this :
{
"manifest_version": 2,
"name": "LinkedIn Adder",
"version": "1.0",
"description": "Allows you to automatically accept connection requests on LinkedIn.",
"icons": {
"16": "add-user.png"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"identity",
"cookies",
"activeTab"
],
"browser_action": {
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": ["https://www.linkedin.com/mynetwork/invitation-manager/"],
"js": ["content.js"]
}
]
}
I can't see my problem, can anyone help?