Skip to content

Instantly share code, notes, and snippets.

@mainnika
Created November 3, 2016 06:38
Show Gist options
  • Save mainnika/a07dbf2c136a04e9742032df50fec9e2 to your computer and use it in GitHub Desktop.
Save mainnika/a07dbf2c136a04e9742032df50fec9e2 to your computer and use it in GitHub Desktop.
ok.ru auto add friends
// when «people you may know» window is open
function add_friends(){
var q = [];
return setInterval(function(){
var r = document.getElementsByName('button_save_rlshp')[0];
if (r) {
r.click();
}
var p = q.pop();
if (!p) {
q = Array.prototype.slice.call(document.getElementsByClassName('mt-x'));
return;
}
p.children[0].children[0].click();
}, 2000);
}
// when notification window is open
function accept_friends(){
Array.prototype.slice.call(document.getElementsByTagName('button')).filter(function(el){
var attr = el.attributes.getNamedItem('data-l')
if (!attr || (attr && attr.nodeValue != 't,btn_accept')) {
return false;
}
return true;
}).forEach(function(el) {
el.click();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment