Created
June 29, 2012 09:17
-
-
Save kopiro/3016868 to your computer and use it in GitHub Desktop.
Autoremove Inactive Friends
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var inactiveFriendsRemover = function() | |
{ | |
var removeAll = function() | |
{ | |
for (var i=0; i<ids.length; i++) | |
{ | |
var id = ids[i]; | |
var as = new AsyncRequest(); | |
as.setURI('/ajax/profile/removefriend.php'); | |
as.setData({ norefresh:true, uid:id }); | |
as.send(); | |
} | |
} | |
var users = document.querySelectorAll('table [ajaxify]'); | |
var ids = []; | |
var names = []; | |
for (var i=0; i<users.length; i++) | |
{ | |
var v = users[i]; | |
if (!v) continue; | |
if (!v.getAttribute) continue; | |
var ajaxify = v.getAttribute('ajaxify'); | |
if (!ajaxify) return; | |
if (ajaxify.match(/inactive/)) | |
{ | |
var id = ajaxify.match(/id=([0-9]*)/)[1]; | |
var name = v.innerHTML; | |
ids.push(id); | |
names.push(name); | |
} | |
} | |
if ( confirm('Are you sure to remove this friends ('+names.length+' users) ?\n' + names.join(', ') ) ) | |
{ | |
removeAll(); | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment