-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsc-unfollowers.js
125 lines (102 loc) · 3.86 KB
/
sc-unfollowers.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* TERMS OF REPRODUCTION USE
*
* 1. Provide a link back to the original repository (this repository), as
* in, https://github.com/ohFRY/soundcloud-followers, that is well-visible
* wherever the source is being reproduced. For example, should you
* display it on a website, you should provide a link above/below that
* which the users use, titled something such as "ORIGINAL AUTHOR".
*
* 2. Retain these three comments: the GNU GPL license statement, this comment,
* and that below it, that details the author and purpose.
*
* Failure to follow these terms will result in me getting very angry at you
* and having your software tweaked or removed if possible. Either way, you're
* still an idiot for not following such a basic rule, so at least I'll have
* that going for me.
*/
/*
* NOTE: This is all procedural as hell because prototypes and any
* OOP techniques in Javascript are stupid and confusing.
*
* @author Fry Falavel
*
* @version 0.1
*/
/*
*
* USAGE: run this script when you are on https://soundcloud.com/{your username}/following
*/
(function () {
function getUsername(){
var a = location.pathname.split("/");
if ( a.length > 1 ) { return a[1]; }
return null;
}
function getMyTab(tab, offset){
var tabb;
$.ajax({
url: 'https://api.soundcloud.com/users/' + SoundcloudUsername + '/followers.json?limit=199&offset='+offset+'&client_id=c431d1033b896faa10f2f5c7eeb8bb9e',//2062cfeb34e8085370a13162c547f4cc',
dataType: 'json',
async: false,
success: function(data) {
tabb = $.merge(tab, data);
}
});
return tabb;
}
function getMyTabs(){
var flag = 0;
var tabbb = [];
while (flag < SoundcloudFollowers) {
tabbb = getMyTab(tabbb, flag);
flag = flag + 198; //limit 198 because of API limit in the results
}
return tabbb;
}
function findUnfollowers() {
var thearray = $('.userBadge__usernameLink').text();
$('.usersList__item').each(function(key, value) {
var found = false;
// browse list of followers
for(var i = 0; i < tab.length; i++) {
if(tab[i].username == $('.userBadge__usernameLink')[key].text) found = true;
}
if (!found) {
$('.sc-truncate', value).append('<span style="color:#F33;size:small">not following back</span>');
}
});
}
var SoundcloudUsername = getUsername();
var tab;
var SoundcloudFollowers;
$.ajax({
url: 'https://api.soundcloud.com/users/'+SoundcloudUsername+'.json?&client_id=c431d1033b896faa10f2f5c7eeb8bb9e',//2062cfeb34e8085370a13162c547f4cc',
dataType: 'json',
async: false,
success: function(data) {
SoundcloudFollowers = data.followers_count;
}
});
setTimeout(function() {
tab = getMyTabs();
if(tab.length >= SoundcloudFollowers) {
setTimeout(findUnfollowers, 1000);
}
} ,1);
// var worker = new Worker(setTimeout(findUnfollowers, 1000));
})();