FVToolkit-AnimalTrafficking

Toolkit for Animal Husbandry. Shortcuts for transferring to own villagers, gender and breedability highlighting.

目前为 2016-08-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         FVToolkit-AnimalTrafficking
// @namespace    CuteHornyUnicorn
// @version      0.1a5
// @description  Toolkit for Animal Husbandry. Shortcuts for transferring to own villagers, gender and breedability highlighting.
// @author       CuteHornyUnicorn
// @include     /^https?://www\.furvilla\.com/career/breeder/[0-9]*
// @grant        none
// ==/UserScript==
/*jshint multistr: true */

var getPage = function(url, callback) {
    var req = new XMLHttpRequest();
    req.onload = function() {
        if ( callback && typeof(callback) === 'function' ) {
            callback( this.responseXML );
        }
    };
    req.open( 'GET', url );
    req.responseType = 'document';
    req.send();
};

getPage( '/profile', function(response) {
    var listVillagers = response.querySelector( '.villagers-list' );
    var vilStore = listVillagers.querySelectorAll('ul > li');


       setInterval(function() {
    if (document.getElementsByClassName('modal-open')[0]) {

var modal = document.querySelector('#modalLabel').textContent.trim();
if (modal == 'Animal Transfer') {
var position = document.querySelector('#modalLabel');
       for (var liContent of vilStore) {
       var VilID = parseInt(liContent.querySelector('a[href^="http://"]').toString().match(/\d+/));
       var CurrentID = parseInt(window.location.href.toString().match(/\d+/));
       var VilName = liContent.querySelector('.villager-name').textContent.trim();
       var VilImg = liContent.getElementsByTagName("img")[0].getAttribute("src");

                        var VilCareer = liContent.querySelector('.villager-info');
       if (VilCareer !== null) {
              VilCareer = VilCareer.textContent.trim().toLowerCase();
           if (VilCareer == 'animal husbandry' && VilID != CurrentID) {
var addbreeder = document.createElement('div');
addbreeder.innerHTML = '<a href="#" style=" margin: 0 10px; float: left; font-size: 12px; font-weight: normal;" onClick="javascript:document.getElementsByName(\'recipient_id\')[0].value='+VilID+'"><img style=\'width: 50px;\' src='+VilImg+' /><br />'+VilName+'</a>';
position.appendChild(addbreeder);
           }    }
}
   }

       if (modal == 'Import Animal') {
var listAnimalsImport = document.querySelector('.inventory');
           var animalStoreImport = listAnimalsImport.querySelectorAll('li > .inventory-item-info');
for (var animalImport of animalStoreImport) {
var isFemaleImport = animalImport.querySelectorAll('p')[1].textContent.match(' Female');
var isReadyImport = animalImport.querySelectorAll('p')[1].textContent.match(' Now');
if (isFemaleImport) {animalImport.style = "box-shadow: 5px 0 5px 0 #ed11e0 inset;";} else {animalImport.style = "box-shadow: 5px 0 5px 0 #178fde inset;";}
if (isReadyImport && isFemaleImport) {animalImport.style = "box-shadow: 5px 0 5px 0 #ed11e0 inset; background: rgba(237,17,224,.5) !important;";}



}
       }

    }
}, 100);

});

var listAnimals = document.querySelector('.animal');
var animalStore =listAnimals.querySelectorAll('li > .animal-item-info');
for (var animal of animalStore) {
    var isempty = animal.querySelectorAll('.name')[0].textContent;
    if (isempty !== 'Empty Slot' && isempty !== 'Add a Stable') {
    var breedable = animal.querySelectorAll('.status')[1].textContent;
    var isfemale = animal.querySelector('.animal-item-info-sex').getElementsByTagName("img")[0].getAttribute("src").match('female');
    if (isfemale) {animal.style = "box-shadow: 5px 0 5px 0 #ed11e0 inset;";} else {animal.style = "box-shadow: 5px 0 5px 0 #178fde inset;";}
    if (breedable == 'Breedable Now'&& isfemale) {animal.style = "box-shadow: 5px 0 5px 0 #ed11e0 inset; background: rgba(237,17,224,.5) !important;";}
    }
}