Autostrife

Automatically strifes on the Overseer project.

目前为 2014-10-24 提交的版本。查看 最新版本

// ==UserScript==
// @name         Autostrife
// @namespace    http://gigapause.com/
// @version      0.9.6
// @description  Automatically strifes on the Overseer project.
// @author       capableResistor
// @grant        none
// @match        http://*.theoverseerproject.com/*
// @match        http://92.222.26.236/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// ==/UserScript==

function strife(){
    var pathArray = window.location.pathname.split( '/' );
    var pathLength = pathArray.length -1;
    var currPath = pathArray[pathLength];
    createInput();
    if(currPath == "dreamtransition.php") {
        printcon("Switching dreamstates, cookie cleansed.");
        unsetCookie('autostrife');
    }
    if($('#aspect').length){
        var healthcontainer = $('#banner > div.intercross > span > div.pined');
        var encountercontainer = $('#banner > div.intercross > div.lefy > span');
        var health = healthcontainer.html();
        var encounters = encountercontainer.html();
        health = health.replace( /^\D+/g, '');
        health = health.replace('%','');
        encounters = encounters.replace( /^\D+/g, '');
        
        document.title = "H: " + Number(health) + "%" + " E: " + Number(encounters) + ". Overseer";
        
        if (getCookie('autostrife') == "") {
            printcon("Autostrife cookie not set. Not autostrifing.");
        } else if (getCookie('autostrife') == "doStrife") {
            if(Number(health) < 20 ) {
                //abscond();
                printcon("Too dangerous to autostrife (Health below 20%). Manual intervention required.");
            } else {
                attack();
            } 
        } else if (getCookie('autostrife') == "doGrind"){
            if (Number(health) < 5 ) {
                printcon("Looks like you're in trouble. Get healed above 5% before you attempt grinding and be sure you're taking on enemies you're very sure you can defeat easily.");
                abscond();
            } else {
                attack();
            }
        } else {
            printcon("Error: Cookie setting mismatch. Resetting cookie.");
            unsetCookie('autostrife');
        }
    } else if ($('#canner a').length > 0 && $.trim($('#canner a').text()) == "Strife again" && getCookie('autostrife') == "doStrife") {
        printcon("Strife concluded.");
        unsetCookie('autostrife');
    } else if ($('#canner a').length > 0 && $.trim($('#canner a').text()) == "Strife again" && getCookie('autostrife') == "doGrind") {
        printcon("Strife concluded, but grind mode is on.");
        window.location.href = 'strife.php';
    } else if ($('input[type="submit"][value="Fight these enemies again!"]').length && getCookie('autostrife') == "doGrind") {
        printcon("On strife init page, and autoGrind is on.");
        var encountercontainer2 = $('#banner > div.intercross > div.lefy > span');
        var encounters2 = encountercontainer2.html();
        encounters2 = encounters2.replace( /^\D+/g, '');
        if (Number(encounters2) === 0) {
            printcon("However, there are no encounters left. Grinding is over.");
            unsetCookie('autostrife');
        } else  {
            printcon("We have " + Number(encounters2) + " enounter(s) to work with.");
            initiate();
        }
    } else {
        printcon("Idle.");
        var encountercontainer3 = $('#banner > div.intercross > div.lefy > span');
        var encounters3 = encountercontainer3.html();
        encounters3 = encounters3.replace( /^\D+/g, '');
        if (Number(encounters3) === 0 && getCookie('autostrife') == "doGrind" ) {
            printcon("There are no encounters left. Grinding is over.");
            unsetCookie('autostrife');
        }
    }
}

function setCookie(cname, cvalue, exdays){
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}

function unsetCookie(cname){
    document.cookie = cname + "=; expires=-90019001";
}

function getCookie(cname){
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
    }
    return "";
}

function createInput(){
    var atbutton = $('input[type="submit"][value="Abscond"]');
    var userinfo = $('#banner > div.intercross > span > div.lined > a');
    var mainbox = $('#banner');
    if (mainbox.length > 0){
        mainbox.after($('<div id="strifeconsole" style="background-color: #AAAAAA; overflow-y: scroll; border: 5px solid #c6c6c6; height: 75px;"></div>'));
        mainbox.after($('<div id="strifebuttons" style="background-color: #AAAAAA; border: 5px solid #c6c6c6; height: 35px;"></div>'));
        var buttonbox = $('#strifebuttons');
        buttonbox.append($('<span class="rhyme slam astop" id="stop">STOPAUTO</span>'));
        buttonbox.append($('<style>#stop {\ncolor: #000;\nmargin-left: 5px;\nmargin-right: 10px;\nmargin-top: 5px;\n}\n#stop:active {\nbackground-color: #444;\ncolor: #FFF;\n}\n#stop:hover {\noutline: thin red solid\n}\n</style>'));
        document.getElementById('stop').addEventListener("click", stop, false);
    }
    if(atbutton.length > 0){
        var buttonbox = $('#strifebuttons');
        buttonbox.append($('<span class="rhyme slam aautos" id="astrife">AUTOSTRIFE</span>'));
        buttonbox.append($('<span class="rhyme slam aautog" id="agrind">AUTOGRIND</span>'));
        buttonbox.append($('<style>#astrife {\ncolor: #000;\nmargin-left: auto;\nmargin-right: 10px;\nmargin-top: 5px;\n}\n#astrife:active {\nbackground-color: #444;\ncolor: #FFF;\n}\n#astrife:hover {\noutline: thin red solid\n}\n</style>'));
        buttonbox.append($('<style>#agrind {\ncolor: #000;\nmargin-left: auto;\nmargin-right: 10px;\nmargin-top: 5px;\n}\n#agrind:active {\nbackground-color: #444;\ncolor: #FFF;\n}\n#agrind:hover {\noutline: thin red solid\n}\n</style>'));
        document.getElementById('astrife').addEventListener("click", autoStrife, false);
        document.getElementById('agrind').addEventListener("click", autoGrind, false);
    }
}

function attack(){
    printcon("Attacking.");
    var atbutton = $('input[type="submit"][value="Attack"]');
    atbutton.trigger("click");
}

function abscond(){
    printcon("Absconding.");
    var abbutton = $('input[type="submit"][value="Abscond"]');
    abbutton.trigger("click");
}

function initiate(){
    printcon("Initiating strife.");
    var lastbutton = $('input[type="submit"][value="Fight these enemies again!"]');
    lastbutton.trigger("click"); 
}

function autoStrife(){
    printcon("Autostrifing.");
    setCookie('autostrife', 'doStrife', '1');
    window.location.href = 'strife.php';
}

function autoGrind(){
    printcon("Autogrinding.");
    setCookie('autostrife', 'doGrind', '7');
    window.location.href = 'strife.php';
}

function stop(){
    if (getCookie('autostrife') === ""){
        printcon("Cookie isn't even set. No need to keep pressing this.");
    } else {
        printcon("Unsetting autostrife and autogrind.");
        unsetCookie('autostrife');
    }
}

function printcon(data){
    var mainconsole = $('#strifeconsole');
    mainconsole.append($('<div style="color: #FFF; background-color: rgba(0,0,0,.20);">[AUTOSTRIFE]====> ' + data + '</div>'));
    mainconsole.scrollTop(($('#strifeconsole').height()*2));
}

setTimeout( strife(), 3000 );

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址