-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
77 lines (63 loc) 路 2.86 KB
/
script.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
THIS FILE WAS DEVELOPED BY MEHMET GUDUK
漏 2022 COPYRIGHT, LICENSED WITH GPL-3.0 LICENSE, AUTHOR IS MEHMET GUDUK
*/
/* TAGS */
let hidden_follower = document.querySelector("#follower");
let hidden_following = document.querySelector("#following");
let input_followers = document.querySelector("#input-followers");
let input_following = document.querySelector("#input-following");
let unfollowers_list = document.querySelector(".unfollowers");
let result_table = document.querySelector(".result-table");
let card_header = document.querySelector(".card-header");
document.querySelector(".fa-search").addEventListener("click", function () {
if (input_followers.value !== "" && input_following.value !== "") {
let following_list = [];
let follower_list = [];
let unfollowers = [];
unfollowers_list.innerHTML = "";
hidden_follower.innerHTML = `${input_followers.value}`
hidden_following.innerHTML = `${input_following.value}`
let following_data = document.querySelectorAll("#following .XiVwj5uoqqSFpS4cYOC6");
let follower_data = document.querySelectorAll("#follower .XiVwj5uoqqSFpS4cYOC6");
following_data.forEach(u => {
let name = u.querySelector(".bFhcPb").textContent;
let url = "https://open.spotify.com" + u.querySelector("a").getAttribute("href");
let img;
try { img = u.querySelector("img").getAttribute("src") }
catch (err) {
img = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/OOjs_UI_icon_userAvatar-invert.svg/1024px-OOjs_UI_icon_userAvatar-invert.svg.png"
}
let user = { name: name, url: url, img: img }
following_list.push(user);
})
follower_data.forEach(u => {
let name = u.querySelector(".bFhcPb").textContent;
follower_list.push(name);
})
following_list.forEach(u => {
if (follower_list.includes(u.name) === false) {
unfollowers.push(u)
}
})
unfollowers.forEach(unfollower => {
unfollowers_list.innerHTML += `<li class="unfollower"><img src="${unfollower.img}"><a href="${unfollower.url}">${unfollower.name}</a></li>`
})
console.log(unfollowers)
if (follower_list.length === 0 && following_list.length === 0) {
card_header.textContent = `Unfollowers`
result_table.style.display = "none";
}
else {
card_header.textContent = `${unfollowers.length} Unfollowers Listed`
result_table.style.display = "block";
}
follower_list = []
following_list = []
input_followers.value = "";
input_following.value = "";
}
else {
result_table.style.display = "none";
}
})