FVToolkit-AnimalTrafficking

Add shortcuts to own Villagers with Animal Husbandry career when transferring animals.

目前為 2016-08-08 提交的版本,檢視 最新版本

// ==UserScript==
// @name         FVToolkit-AnimalTrafficking
// @namespace    CuteHornyUnicorn
// @version      0.1a1
// @description  Add shortcuts to own Villagers with Animal Husbandry career when transferring animals.
// @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 ulStore = 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 ulStore) {
       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) {
//           alert(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);
           }    }
}
   }
    }
}, 1000);

});