Skip to content

Instantly share code, notes, and snippets.

@shakkurcwb
Last active September 25, 2023 18:19
Show Gist options
  • Save shakkurcwb/133ae8b5ae561cfffb6324e882547092 to your computer and use it in GitHub Desktop.
Save shakkurcwb/133ae8b5ae561cfffb6324e882547092 to your computer and use it in GitHub Desktop.
/**
* Script for Auto-Reply Comments on LinkedIn.
* 1 - Open a Post Page on LinkedIn (URL like "/feed/update/");
* 2 - Copy and Paste this code into your Browser Console Tab, then press ENTER.
* Be polite when using it. I am not responsible for bad usage!
* CHANGESLOG:
* 1 - Added auto-liker comment.
* @author ma.ferreira93@gmail.com
*/
var CustomMessage = "Obrigado pelo seu interesse neste material. Fique de olho em seu e-mail!";
function load() {
var postCommentsList = $(".comments-comments-list");
postCommentsList.promise().done(function() {
if (this && this.length > 0) {
// To be safe, lets just enter on the first node (first post)
var commentsList = this[0];
var articles = $(commentsList).find("article").promise().done(function() {
if (this && this.length > 0) {
this.each(function () {
var article = this;
ReplyComment(article, function (article) {
console.log('Done ReplyComment', article);
LikeComment(article, function (article) {
console.log('Done LikeComment', article);
FillCommentAnswer(article, function (article) {
console.log('Done FillCommentAnswer', article);
SendCommentAnswer(article, function (article) {
console.log('Done SendCommentAnswer', article);
});
});
});
});
})
}
});
}
});
}
var ReplyComment = function(article, callback) {
console.log('ReplyComment');
setTimeout(function() { // fake async
var replyButton = article.querySelector('.comments-comment-social-bar__reply-action-button');
replyButton.click();
callback(article); // fake promise.then
}, 250);
};
var FillCommentAnswer = function(article, callback) {
console.log('FillCommentAnswer');
setTimeout(function() { // fake async
var textEditor = article.querySelector('.mentions-texteditor__content');
$(textEditor).html(CustomMessage);
callback(article); // fake promise.then
}, 250);
};
var SendCommentAnswer = function(article, callback) {
console.log('SendCommentAnswer');
setTimeout(function() { // fake async
var sendButton = article.querySelector('.comments-comment-box__submit-button');
sendButton.click();
callback(article); // fake promise.then
}, 500);
};
var LikeComment = function(article, callback) {
console.log('LikeComment');
setTimeout(function() { // fake async
var likeButton = article.querySelector('.comments-comment-social-bar__like-action-button');
likeButton.click();
callback(article); // fake promise.then
}, 250);
};
load();
@phanquangkiev
Copy link

Doesn't seem to work. Could you make a quick video tutorial? I would really appreciate it

@tijgersoftware
Copy link

same doesn't seem to work anyone fixed the script? I get error:

VM84:15 Uncaught TypeError: postCommentsList.promise is not a function
at load (:15:22)
at :78:1

@shakkurcwb
Copy link
Author

The script does not work since 2021 - it is kept here only for historical purposes.
LinkedIn removed JQuery dependency from it's app, so we lost the ability to easily interact with the app and manipulate the DOM.
If you need to automate tasks or simulate navigation, search for Scrapping and/or E2E - BeautifulSoup, Selenium, Cypress, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment