-
-
Save berstend/7760130 to your computer and use it in GitHub Desktop.
var INCR = 16; // Number of messages per page | |
var SENT_URL = '//www.linkedin.com/inbox/invitations/sent?startRow='; | |
var loMessageLinks = []; // Main array for all contacts | |
var fetchMessages = function(i, cb) { | |
console.log('Fetching message page #' + (i+1)); | |
$.get(SENT_URL + (i*INCR), function(data){ | |
var $dom = $(data); | |
var items = [] | |
$dom.find('.inbox-item .detail-link').each(function(i){ | |
items.push($(this).attr('href')); | |
}); | |
if (items.length > 0) { | |
console.log(' > Found ' + items.length + ' messages on page #' + (i+1) + ', ' + (loMessageLinks.length+items.length) + ' in total.'); | |
$.merge(loMessageLinks, items); | |
cb(); | |
} else { | |
console.log(' > No messages found.') | |
cb(new Error); | |
} | |
}) | |
} | |
var followMessageLink = function(link, cb){ | |
$.get(link, function(data){ | |
var $dom = $(data); | |
var $el = undefined; | |
var actionURL = undefined; | |
$el = $dom.find(".btn-quaternary:contains('Withdraw')"); | |
if ($el.length > 0) { | |
console.log(' > Withdraw'); | |
$.get($el.attr('href'), function(data){ | |
cb(); | |
}); | |
} else { | |
$el = $dom.find(".btn-quaternary:contains('Archive')"); | |
console.log(' > Archive'); | |
$.get($el.attr('href'), function(data){ | |
cb(); | |
}); | |
} | |
}); | |
} | |
iRun = 0; | |
var iMessage = 0; | |
var z = undefined; | |
var fetchMessageCallback = function(err) { | |
if (err) { | |
console.log('Finished message collecting. One moment please..'); | |
z = setInterval(function(){ | |
console.log('Processing message #' + (iMessage+1) + '/' + loMessageLinks.length); | |
followMessageLink(loMessageLinks[iMessage], function(){ }); | |
iMessage = iMessage + 1; | |
if (iMessage >= loMessageLinks.length) { | |
console.log('ALL DONE'); | |
clearInterval(z); | |
} | |
}, 5000); | |
} else { | |
iRun = iRun+1; | |
fetchMessages(iRun, fetchMessageCallback); | |
} | |
} | |
fetchMessages(0, fetchMessageCallback); |
Doesn't work so well. But found this which is perfect: https://support.dux-soup.com/article/143-cancel-pending-invites
This worked for me in November 2020.
WEB:
var button1 = document.getElementsByClassName("invitation-card__action-btn artdeco-button artdeco-button--muted artdeco-button--3 artdeco-button--tertiary ember-view")
var button2 = document.getElementsByClassName("artdeco-modal__confirm-dialog-btn artdeco-button artdeco-button--2 artdeco-button--primary ember-view")
setInterval(()=>{
for(var i=0;i<button1.length;i++){
button1[i].click()
button2[0].click()}},1000)
Mobile:
var button1 = document.getElementsByClassName("rect-btn rect-btn_muted_tertiary rect-btn_muted rect-btn_regular ripple invite-card-withdraw-btn js-withdraw-invite-btn js-rect-btn")
var button2 = document.getElementsByClassName("rect-btn rect-btn_tertiary rect-btn_regular ripple primary-action js-rect-btn")
setInterval(()=>{
for(var i=0;i<button1.length;i++){
button1[i].click()
button2[0].click()}},1000)
Good luck.
Thanks @nijatmursali your web script worked for me :) It seems like it withdrew 98 invitations (on the single page) each time I ran it, so if you have multiple pages, repeat the script.
@nijatmursali Thanks, Brother!!
Your Web Script Worked for me :)
Good luck guys. I also added it to my gists, I will make changes for it to work without refreshing.
A simple script to remove those pending sent invitations, can be found at https://github.com/abhisheksarkar30/js-stuffs/blob/master/Scripts/WithdrawAllSentRequestsOnLinkedIn.js
This worked for me in November 2020.
WEB:
var button1 = document.getElementsByClassName("invitation-card__action-btn artdeco-button artdeco-button--muted artdeco-button--3 artdeco-button--tertiary ember-view") var button2 = document.getElementsByClassName("artdeco-modal__confirm-dialog-btn artdeco-button artdeco-button--2 artdeco-button--primary ember-view") setInterval(()=>{ for(var i=0;i<button1.length;i++){ button1[i].click() button2[0].click()}},1000)
Mobile:
var button1 = document.getElementsByClassName("rect-btn rect-btn_muted_tertiary rect-btn_muted rect-btn_regular ripple invite-card-withdraw-btn js-withdraw-invite-btn js-rect-btn") var button2 = document.getElementsByClassName("rect-btn rect-btn_tertiary rect-btn_regular ripple primary-action js-rect-btn") setInterval(()=>{ for(var i=0;i<button1.length;i++){ button1[i].click() button2[0].click()}},1000)
Good luck.
July 6 2021
Working
Thanks
This Worked for me in 2021- 2022
var button1 = document.getElementsByClassName("invitation-card__action-btn artdeco-button artdeco-button--muted artdeco-button--3 artdeco-button--tertiary ember-view")
var button2 = document.getElementsByClassName("artdeco-modal__confirm-dialog-btn artdeco-button artdeco-button--2 artdeco-button--primary ember-view")
setInterval(()=>{
for(var i=0;i<button1.length;i++){
button1[i].click()
button2[0].click()}},1000)
Enjoy - from othership.com
var button1 = document.getElementsByClassName("invitation-card__action-btn artdeco-button artdeco-button--muted artdeco-button--3 artdeco-button--tertiary ember-view")
var button2 = document.getElementsByClassName("artdeco-modal__confirm-dialog-btn artdeco-button artdeco-button--2 artdeco-button--primary ember-view")
setInterval(()=>{
for(var i=0;i<button1.length;i++){
button1[i].click()
while(button2.length > 0) {
button2[0].click()
break
}
}},1000)
you can go the the page with the maximum age of pending invitations that you like to keep, for example 1 month old, and then run the script, as it takes only the buttons that are page elements in the current page loading state, it will then delete all requests that are older until it has finished till the last page. you just have to close the browser window if it starts to remove the requests that you want to keep :)