-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkedminus.js
More file actions
50 lines (50 loc) · 1.74 KB
/
linkedminus.js
File metadata and controls
50 lines (50 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button[aria-label^="Click to stop following"]') || [];
}
async function loadAll() {
let lastHeight = 0;
while (document.body.scrollHeight > lastHeight) {
lastHeight = document.body.scrollHeight;
window.scrollTo(0, lastHeight);
await new Promise(resolve => setTimeout(resolve, 500));
}
}
async function unfollowAll() {
const buttons = getAllButtons();
for (let button of buttons) {
count++;
const ariaLabel = button.getAttribute('aria-label');
const name = ariaLabel.replace('Click to stop following ', '');
console.log(
`%c #${count} %c 👋 Unfollowed %c ` + name + ` `,
'color: #fff; background-color:#34495e',
'color: #fff; background-color:#27ae60',
'color: #000; background-color:#95a5a6'
);
window.scrollTo(0, button.offsetTop - 260);
button.click();
await new Promise(resolve => setTimeout(resolve, 100));
}
}
async function processTab(tabText) {
const tabButton = Array.from(document.querySelectorAll('button.artdeco-tab')).find(b => b.innerText.trim() === tabText);
if (tabButton) {
tabButton.click();
await new Promise(resolve => setTimeout(resolve, 1000));
await loadAll();
await unfollowAll();
}
}
async function run() {
await processTab('Following');
await processTab('Followers');
if (confirm('🥳 Done! We unfollowed ' + count + ' connections. Do you want to reload the page to update?')) {
location.reload();
}
}
if (confirm('👋 Hi, are you willing to clear up your feed and unfollow all of your connections in both tabs? Then press "OK".')) {
run();
}
})();