FVToolkit-Sidebar

scrollable sidebar with all villagers

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         FVToolkit-Sidebar
// @namespace    CuteHornyUnicorn
// @version      0.1a2
// @description  scrollable sidebar with all villagers
// @author       CuteHornyUnicorn
// @include      http://www.furvilla.com/*
// @grant        none
// ==/UserScript==
/*jshint multistr: true */


var sidebar = document.createElement('div');
sidebar.setAttribute('class', 'FVTK-rsidebar');
sidebar.style = 'position: fixed;\
    right: -20px;\
    top: -20px;\
    overflow:scroll;\
    height: 108%;\
    width: 230px;\
    visibility: hidden;\
';

sidebar.innerHTML = '\
    <div class="widget">\
         <div class="widget-content" style="visibility: visible;">\
         </div>\
    </div>\
';

document.body.appendChild(sidebar);


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 sidebarWidget = document.querySelector( '.FVTK-rsidebar > .widget' );
    var sidebarWidgetContent = sidebarWidget.querySelector('.widget-content');
    var listVillagers = response.querySelector( '.villagers-list' );
    var ulStore = listVillagers.querySelectorAll('ul > li');
   for (var liContent of ulStore) {
              var VilCareer = liContent.querySelector('.villager-info').textContent.trim().toLowerCase();
              if (VilCareer == 'animal husbandry') {
                  VilCareer = 'breeder';
              }
                     if (VilCareer == 'construction worker') {
                  VilCareer = 'carpenter';
              }
       var replaceLinks = liContent.innerHTML;
         replaceLinks = replaceLinks.replace('villager/','career/'+VilCareer+'/');
//       replaceLinks = replaceLinks.split('villager/').join('career/'+VilCareer+'/');
       liContent.innerHTML = replaceLinks;
var villager = document.createElement('div');
villager.setAttribute('class', 'text-center');
sidebarWidgetContent.appendChild(villager);       
villager.innerHTML = replaceLinks; 
   }
});


function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}

	addGlobalStyle("\
\
.FVTK-rsidebar .text-center {\
text-align: left;\
height: 80px;\
}\
.FVTK-rsidebar .text-center .villager-avatar {\
width:75px;\
border-radius: 0px !important;\
}\
\
.FVTK-rsidebar .text-center p {\
text-align: left;\
font-size: 10px;\
width: 60%;\
position: relative;\
top: -80px;\
margin-left: 80px;\
margin-bottom: 0px;\
}\
\
.FVTK-rsidebar .text-center p a {\
}\
");