EggCave - Auto Feeder

Automatically feeds creatures on the site

This script is marked as "external"
This script was commisioned by someone else, and I will not check if it works. If it breaks, contact me
Click here to install Browse More Scripts
// ==UserScript==
// @name         EggCave - Auto Feeder
// @namespace    64a4b10c9521815b2a958be7b7a132dcd5014cb4
// @version      0.1
// @description  Automatically feeds creatures on the site
// @author       /u/AyrA_ch
// @match        https://www.eggcave.com/egg/*
// @grant        none
// @external     true
// @run-at       document-idle
// ==/UserScript==

(function ($, $$) {
	//There are two buttons and the real one is the last in the list. The first one is the loader placeholder
	var btnFeed = Array.prototype.slice.call($$("button.button.is-info")).pop();
	var checkUpdate = function () {
		//Continue only if the button text changed to something that ends in "(+n EZ)"
		if (btnFeed.textContent.match(/([-+]\d+\sEC)/i)) {
			//Button to advance exists only once (for now)
			var btnNext = $(".fa-arrow-right");
			if (btnNext) {
				//Button to advance is actually a link so we just set the href property as new target.
				document.location.href = btnNext.parentNode.href;
			} else {
				alert("Script ended, no 'next' button found");
			}
		}
	};
	//This scans for changes in the document tree
	var mo = new MutationObserver(checkUpdate);
	//Limit to attributes and text content
	var config = {
		attributes: true,
		childList: false,
		characterData: true,
		subtree: false
	};
	//Attach event only if button was actually found
	if (btnFeed && !btnFeed.disabled) {
		mo.observe(btnFeed, config);
		btnFeed.click();
	} else {
		alert("Unable to locate clickable 'feed' button");
	}
})(document.querySelector.bind(document), document.querySelectorAll.bind(document));

/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.

DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/

Copyright © 2018 by Kevin Gut 📧 | More services | Generated for 3.143.218.146