Skip to content

Instantly share code, notes, and snippets.

@max-frai
Created April 28, 2017 13:32
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save max-frai/d3e83efd8e6c87b498e5443d6bae035f to your computer and use it in GitHub Desktop.
Save max-frai/d3e83efd8e6c87b498e5443d6bae035f to your computer and use it in GitHub Desktop.
Leave facebook public groups
// https://www.facebook.com/groups/?category=groups
var formSelector = 'form[action*="leave.php"]';
var leavePause = 4 * 1000;
var leftGroupsCount = 0;
var leaveGroupTitle = "";
function waitFor(selector) {
return new Promise(function(resolve, reject) {
var interval = window.setInterval(function() {
var container = document.querySelector(selector);
if (container.length) {
resolve(container);
window.clearInterval(interval);
}
}, 500, resolve);
});
}
var clickInterval = window.setInterval(function() {
var decline = document.querySelector('a[ajaxify*="leave.php"]');
if (!decline) {
console.log('Finish!');
window.clearInterval(clickInterval);
return;
}
try {
groupTitle = decline.parentNode.parentNode.parentNode.querySelector('a[href*="group_browse_new"]').textContent;
} catch(e) {groupTitle = '';}
decline.click();
waitFor(formSelector).then(function() {
document.querySelector(formSelector + ' .uiInputLabelLabel').click();
document.querySelector(formSelector + ' button.layerConfirm').click();
leftGroupsCount += 1;
console.log('#' + leftGroupsCount + ' ' + groupTitle + ' — unsubscribed');
decline.parentNode.removeChild(decline);
});
}, leavePause);
@themkvz
Copy link

themkvz commented Sep 7, 2018

Что то перестало работать
http://joxi.ru/vAWngKwH1a9xP2?d=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment