Skip to content

Instantly share code, notes, and snippets.

@Koopzington
Last active May 31, 2018 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Koopzington/a13d421ff3bf65f49b3348b5dc0d7962 to your computer and use it in GitHub Desktop.
Save Koopzington/a13d421ff3bf65f49b3348b5dc0d7962 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name GIVE ALL THE LLAMAS - Group Memberlist
// @namespace http://github.com/koopzington/
// @version 1.2.3
// @description Script to let your browser automatically click you One-Click-Llama-Buttons on memberlists of groups
// @author Koopzington
// @match https://*.deviantart.com/modals/memberlist*
// @match https://www.deviantart.com/*/modals/memberlist*
// @downloadURL https://gist.githubusercontent.com/Koopzington/a13d421ff3bf65f49b3348b5dc0d7962/raw/give-all-the-llamas.user.js
// @grant none
// ==/UserScript==
window.addEventListener('load', function() {
'use strict';
var totalOCLBs = document.querySelectorAll('.oclb').length;
var doneOCLBs;
var spamTimeOut = 15 * 60 * 1000; // 15 minutes
var loopSpeed = 10 * 1000; // 10 seconds
var originalTitle = document.title;
var waiting = false;
searchAndClick();
function updateDone() {
doneOCLBs = document.querySelectorAll('.oclb-success').length +
document.querySelectorAll('.oclb-already').length +
document.querySelectorAll('.oclb-100k').length +
document.querySelectorAll('.oclb-enough').length;
}
function searchAndClick() {
setTimeout(function () {
if (! waiting) {
updateDone();
console.log('Current Page: ' + doneOCLBs + '/' + totalOCLBs + ' llamas given');
if (document.querySelectorAll('.oclb-spam').length > 0) {
console.log('We hit the spam limit, let\'s chill a bit...');
waiting = Date.now() + spamTimeOut;
setTimeout(function () {
waiting = false;
}, spamTimeOut);
} else {
document.title = '\u25b6 ' + originalTitle;
var elements = document.querySelectorAll('.oclb-give, .oclb-error');
if (elements.length > 0) {
elements[0].click();
}
if (doneOCLBs === totalOCLBs) {
console.log('Page done. Proceeding with next one.');
window.location = document.querySelector('li.next a.away').href;
}
}
} else {
document.title = '\u25a0 (' + Math.ceil((waiting - Date.now()) /1000) + 's) ' + originalTitle;
}
searchAndClick();
}, loopSpeed);
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment