BvS Banked Hangouts

Modifies the Top Friend Rankings page to show only the allies you need to hang out with for retail

目前為 2014-10-30 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        BvS Banked Hangouts
// @description Modifies the Top Friend Rankings page to show only the allies you need to hang out with for retail
// @namespace   Terrec
// @include     http://*animecubed.com/billy/bvs/shop-retail.html
// @include     http://*animecubed.com/billy/bvs/team.html
// @include     http://*animecubed.com/billy/bvs/friends.html
// @include     http://*animecubed.com/billy/bvs/oneuseitems.html
// @include     http://*animecubed.com/billy/bvs/missions/*
// @version     1.3
// @history     1.3 Rankings page now defaults to only showing allies that need hangouts
// @history     1.2 Bugfix, compatibility fix for the Ally Types script, added friend point updater to missions, added the heng to the Rankings page, and changed the current friend points colors from red/black to blue/green
// @history     1.1 Added alt compatibility, added a mark next to the friend points of allies that need hangouts on the team page, and reworked the Rankings page changes
// @history     1.0 Initial release
// @grant       GM_setValue
// @grant       GM_getValue
// ==/UserScript==

var alt = document.evaluate("//input[@name='player' and @type='hidden']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if(alt)
    alt = alt.value;
else alt = GM_getValue('lastAlt');
GM_setValue('lastAlt',alt);
var data = JSON.parse(GM_getValue(alt,'{}'));
if(!data.banked)
    data.banked = [];

function marker() {
    var marker = document.createElement('b');
    marker.style.color = 'red';
    marker.textContent = ' ꜧ';
    return marker;
}

if (/animecubed.com\/billy\/bvs\/shop-retail.html/.test(location.href)) {
    var font = document.getElementsByTagName('font');
    if (document.body.textContent.indexOf('Bonus Shifts given: ')>-1){
        var img = document.querySelectorAll("img[src^='/billy/layout/nin/']");
        for(var j=0; j<img.length; j++) {
            var temp = data.banked.indexOf(img[j].attributes.src.value.replace(/_/g,' ').replace('/billy/layout/nin/','').replace(/(?: Lvl\. \d)?\.gif/,''));
            if(temp>-1)
                data.banked.splice(temp,1);
        }
        GM_setValue(alt, JSON.stringify(data));
    }
    else for (var i = 0; i < font.length; i++) {
        if (font[i].textContent.indexOf('(Allies who owe you one: ') > -1) {
            data.banked = font[i].textContent.replace(/ Lvl\. \d/g, '').slice(25, - 1).split(', ');
            GM_setValue(alt, JSON.stringify(data));
            break;
        }
    }
}

if (/animecubed.com\/billy\/bvs\/oneuseitems.html/.test(location.href)&&document.body.textContent.indexOf('Sneaky Potato Used!') > -1) {
    var pitem = document.getElementById('pitem').getElementsByTagName('i');
    for(var i=0; i<pitem.length; i++){
        var temp = pitem[i].textContent.match(/20 \/ 20: (.*) offers a shift for the potato!/);
        if(temp) {
            data.banked.push(temp[1].replace(/ Lvl\. \d/,''));
            GM_setValue(alt, JSON.stringify(data));
        }
    }
}

if (/animecubed.com\/billy\/bvs\/team.html/.test(location.href)) {
    data.allies=[];
    data.friendPoints=[];
    if (document.body.innerHTML.indexOf("<b>Reorganize Allies</b>") > -1) {
        var allyList = document.getElementById('teamrep').getElementsByTagName('tr');
        for (var i = 0; i < allyList.length; i++) {
            var b = allyList[i].getElementsByTagName('b')[0];
            var newAlly = b.textContent.replace(/ Lvl\. ./g, '').replace(/\[.*\]/,"");
            data.allies.push(newAlly);
            var parent = b.parentNode;
            var fpNode;
            for(var j=0; j < parent.children.length; j++)
                if(parent.children[j].textContent.indexOf('Friend Points: ') > -1)
                    fpNode = parent.children[j];
            var newAllyFP = fpNode.textContent.match(/\(Friend Points: (.*)\)/)[1]
            data.friendPoints.push(newAllyFP);
            if (data.banked.indexOf(newAlly) == -1) {
                //Mark the ally as needing a hangout
                parent.insertBefore(marker(),fpNode.nextSibling);
            }
        }
        GM_setValue(alt, JSON.stringify(data));
    }
}

if(!data.allies)
    data.allies=[];
if(!data.friendPoints)
    data.friendPoints=[];
var needMoreLove = [];

if (/animecubed.com\/billy\/bvs\/missions/.test(location.href)) {
    if(document.body.textContent.indexOf('Jutsu XP:') > -1){
        var span = document.getElementsByTagName('span');
        for(var i = 0; i<span.length; i++){
            if(span[i].title.indexOf('Friend Points: ')>-1){
                var ally = span[i].title.match(/header=\[(.*)\] body/)[1].replace(/ Lvl\. \d/,'');
                var FP = span[i].title.match(/Friend Points\: (.*)\s\s\] offsetx/)[1];
                if(data.allies.indexOf(ally)>-1)
                    data.friendPoints[data.allies.indexOf(ally)]=FP;
            }
        }
        GM_setValue(alt, JSON.stringify(data));
    }
}

if (/animecubed.com\/billy\/bvs\/friends.html/.test(location.href)) {
    var friendList = document.getElementsByTagName('i');
    for (var i = 0; i < friendList.length; i++) {
        var newAlly = friendList[i].textContent;

        var td = friendList[i].parentNode.parentNode.nextElementSibling.getElementsByTagName('td')[1];
        var targetFP = td.innerHTML.replace(/,/g,'').match(/(\d+)/g);
        if(targetFP.length==10)
            targetFP = targetFP[targetFP.length-1];
        else targetFP = 1499;
        var span = document.createElement('span');
        friendList[i].parentNode.appendChild(span);
        span.innerHTML="<br>"+data.friendPoints[data.allies.indexOf(newAlly)];
        if(data.allies.indexOf(newAlly)==-1)
            span.innerHTML="<br><br>";
        if(parseInt(span.textContent.replace(/,/g,''))<targetFP)
            span.style.color='blue';
        else span.style.color='green';
        if (data.banked.indexOf(newAlly)==-1&&data.allies.indexOf(newAlly)>-1) {
            span.parentNode.insertBefore(marker(),span);
            needMoreLove.push(friendList[i].parentNode.parentNode.parentNode.parentNode.parentNode.cloneNode(true))
        }
    }
    var table = friendList[0].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
    while(needMoreLove.length>0){
        var tr = document.createElement('tr');
        tr.style.display = 'none';
        table.appendChild(tr);
        tr.appendChild(needMoreLove.shift());
        if(needMoreLove.length>0)
            tr.appendChild(needMoreLove.shift());
    }
    var toggle = document.createElement('a');
    toggle.href = 'javascript:void(0);'
    toggle.setAttribute("onclick","var table=this.parentNode.parentNode.parentNode;for( var i=1; i < table.children.length; i++){if(table.children[i].style.display=='')table.children[i].style.display='none'; else table.children[i].style.display='';} if(this.textContent=='Show All Allies') this.textContent='Hide Banked/Unobtained Allies'; else this.textContent='Show All Allies';");
    toggle.textContent = 'Hide Banked/Unobtained Allies';
    table.children[0].firstChild.appendChild(toggle);
    toggle.click();
}