Advertisement
Guest User

Untitled

a guest
Jan 27th, 2018
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name            Harem Heroes++
  3. // @namespace       haremheroes.com
  4. // @description     Adding things here and there in Harem Heroes game.
  5. // @version         0.05.2-pullrequest
  6. // @match           http://nutaku.haremheroes.com/*
  7. // @match           https://www.hentaiheroes.com/*
  8. // @match           https://www.gayharem.com/*
  9. // @run-at          document-end
  10. // @grant           none
  11. // @author          Raphael
  12. // ==/UserScript==
  13.  
  14. /* ==================
  15.       localStorage
  16.    ==================
  17.     - lsMarket              (updated each time you enter the Market / click buttons in Market)
  18.         .buyable
  19.             .potion.Nb      = number of buyable books
  20.             .potion.Xp      = total xp of buyable books
  21.             .potion.Value   = cost of buyable books
  22.             .gift.Nb        = number of owned gifts
  23.             .gift.Xp        = total affection of buyable gifts
  24.             .gift.Value     = cost of buyable gifts
  25.         .stocks
  26.             .armor.Nb       = number of owned equipments
  27.             .booster.Nb     = number of owned boosters
  28.             .potion.Nb      = number of owned books
  29.             .potion.Xp      = total xp you can give to your girls
  30.             .gift.Nb        = number of owned gifts
  31.             .gift.Xp        = total affection you can give to your girls
  32.         .restock
  33.             .herolvl        = hero level before restock
  34.             .time           = next market restock time
  35.    ================== */
  36.  
  37. var CurrentPage = window.location.pathname;
  38.  
  39. // css define
  40. var sheet = (function() {
  41.     var style = document.createElement('style');
  42.     document.head.appendChild(style);
  43.     return style.sheet;
  44. })();
  45.  
  46. // verify localstorage
  47. var lsAvailable = (lsTest() === true) ? 'yes' : 'no';
  48.  
  49. FightATroll();                                                      // added everywhere
  50. if (CurrentPage.indexOf('shop') != -1) ModifyMarket();              // Current page: Market
  51. else if (CurrentPage.indexOf('harem') != -1) ModifyHarem();         // Current page: Harem
  52. else if (CurrentPage.indexOf('quest') != -1) ModifyScenes();        // Current page: Haremettes' Scenes
  53.  
  54.  
  55. /* ======================
  56.      Fight A Troll Menu
  57.    ====================== */
  58.  
  59. function FightATroll() {
  60.     // Trolls' database
  61.     var Trolls = ['Dark Lord', 'Ninja Spy', 'Gruntt', 'Edwarda', 'Donatien', 'Silvanus', 'Bremen', 'Finalmecia'];
  62.  
  63.     // get current world of player
  64.     var CurrentWorld = Hero.infos.questing.id_world - 1,
  65.         TrollName = '',
  66.         TrollsMenu = '';
  67.  
  68.     // generate troll list
  69.     for (var i = 0; i < CurrentWorld; i++) {
  70.         if (typeof Trolls[i] !== typeof undefined && Trolls[i] !== false) {
  71.             TrollName = Trolls[i];
  72.         } else TrollName = 'World ' + (i+1) + ' troll';
  73.         TrollsMenu += '<a href="/battle.html?id_troll=' + (i+1) + '">' + TrollName + '</a><br />';
  74.     }
  75.  
  76.     // display: 'Fight a troll' menu
  77.     $('#contains_all > header').children('[type=energy_fight]').append('<div id="FightTroll">Fight a Troll<span class="Arrow"></span><div class="TrollsMenu">' + TrollsMenu + '</div></div>');
  78.  
  79.     // -----------------
  80.     //     CSS RULES
  81.     // -----------------
  82.  
  83.     sheet.insertRule('#FightTroll {'
  84.                         + 'position: absolute;'
  85.                         + 'z-index: 99;'
  86.                         + 'width: 90%;'
  87.                         + 'margin:21px 0 0 13px;'
  88.                         + 'border-radius: 8px 10px 10px 8px;'
  89.                         + 'background: rgba(102,136,153,0.67);'
  90.                         + 'box-shadow: 0 0 0 1px rgba(255,255,255,0.73);'
  91.                         + 'text-align: center; }');
  92.  
  93.     sheet.insertRule('#FightTroll > .Arrow {'
  94.                         + 'float:right;'
  95.                         + 'background-image: url("http://i.harem-battle.club/images/2017/09/19/Fmo.png");'
  96.                         + 'background-size: 18px 18px;'
  97.                         + 'background-repeat: no-repeat;'
  98.                         + 'width: 18px;'
  99.                         + 'height: 18px; }');
  100.  
  101.     sheet.insertRule('#FightTroll > .TrollsMenu {'
  102.                         + 'position: absolute;'
  103.                         + 'width: 88%;'
  104.                         + 'margin-left:6px;'
  105.                         + 'border-radius: 0px 0 8px 8px;'
  106.                         + 'background: rgba(102,136,153,0.67);'
  107.                         + 'line-height: 15px;'
  108.                         + 'opacity: 0;'
  109.                         + 'visibility: hidden;'
  110.                         + 'transition: opacity 400ms, visibility 400ms; }');
  111.  
  112.     sheet.insertRule('#FightTroll:hover > .TrollsMenu {'
  113.                         + 'opacity: 1;'
  114.                         + 'visibility: visible; }');
  115.  
  116.     sheet.insertRule('#FightTroll a {'
  117.                         + 'color: rgb(255, 255, 255);'
  118.                         + 'text-decoration: none; }');
  119.  
  120.     sheet.insertRule('#FightTroll a:hover {'
  121.                         + 'color: rgb(255, 247, 204);'
  122.                         + 'text-decoration: underline; }');
  123. }
  124.  
  125.  
  126. /* ==========
  127.      Market
  128.    ========== */
  129.  
  130. function ModifyMarket() {
  131.     var lsMarket = {};
  132.     lsMarket.buyable = {};
  133.     lsMarket.stocks = {};
  134.     lsMarket.restock = {};
  135.  
  136.     setTimeout( function() {
  137.         // save time of restock
  138.         var RestockTimer = $('#shop > .shop_count > span').text().split(':'),
  139.             s = 0, m = 1;
  140.         // convert HH:MM:SS or MM:SS or SS to seconds
  141.         while (RestockTimer.length > 0) {
  142.             s += m * parseInt(RestockTimer.pop(), 10);
  143.             m *= 60;
  144.         }
  145.         lsMarket.restock.herolvl = Hero.infos.level;
  146.         lsMarket.restock.time = (new Date()).getTime() + s*1000;
  147.  
  148.         // first load
  149.         get_buyableStocks('potion');
  150.         get_buyableStocks('gift');
  151.         equipments_shop(0);
  152.         boosters_shop(0);
  153.         books_shop(0);
  154.         gifts_shop(0);
  155.     }, 500 );
  156.  
  157.  
  158.     // catch click on Buy, Restock, Equip/Offer or Sell > update tooltip after 500ms
  159.     var timer;
  160.     $('#shop > button, #inventory > button').click(function() {
  161.         var clickedButton = $(this).attr('rel'),
  162.             opened_shop = $('#shop').children('.selected');
  163.         clearTimeout(timer); // kill previous update
  164.         timer = setTimeout( function() {
  165.             if (opened_shop.hasClass('armor')) {
  166.                 equipments_shop(1);
  167.             } else if (opened_shop.hasClass('booster')) {
  168.                 boosters_shop(1);
  169.             } else if (opened_shop.hasClass('potion')) {
  170.                 if (clickedButton == 'buy' || clickedButton == 'shop_reload') get_buyableStocks('potion');
  171.                 books_shop(1);
  172.             } else if (opened_shop.hasClass('gift')) {
  173.                 if (clickedButton == 'buy' || clickedButton == 'shop_reload') get_buyableStocks('gift');
  174.                 gifts_shop(1);
  175.             }
  176.         }, 500 );
  177.     });
  178.  
  179.     function get_buyableStocks(loc_class) {
  180.         // initialize
  181.         var itemsNb = 0,
  182.             itemsXp = 0,
  183.             itemsPrice = 0,
  184.             loc = $('#shop').children('.' + loc_class);
  185.         // get stats
  186.         loc.find('.slot').each(function() {
  187.             if ($(this).hasClass('empty')) return false;
  188.             var item = $(this).data('d');
  189.             itemsNb++;
  190.             itemsXp += parseInt(item.value, 10);
  191.             itemsPrice += parseInt(item.price, 10);
  192.         });
  193.         // save
  194.         lsMarket.buyable[loc_class] = {'Nb':itemsNb, 'Xp':itemsXp, 'Value':itemsPrice};
  195.     }
  196.  
  197.     function equipments_shop(update) {
  198.         tt_create(update, 'armor', 'EquipmentsTooltip', 'equipments', '');
  199.     }
  200.     function boosters_shop(update) {
  201.         tt_create(update, 'booster', 'BoostersTooltip', 'boosters', '');
  202.     }
  203.     function books_shop(update) {
  204.         tt_create(update, 'potion', 'BooksTooltip', 'books', 'Xp');
  205.     }
  206.     function gifts_shop(update) {
  207.         tt_create(update, 'gift', 'GiftsTooltip', 'gifts', 'affection');
  208.     }
  209.  
  210.     // create/update tooltip & save to localstorage
  211.     function tt_create(update, loc_class, tt_class, itemName, itemUnit) {
  212.         // initialize
  213.         var itemsNb = 0,
  214.             itemsXp = (itemUnit === '') ? -1 : 0,
  215.             itemsSell = 0,
  216.             loc = $('#inventory').children('.' + loc_class);
  217.  
  218.         // get stats
  219.         loc.find('.slot').each(function() {
  220.             if ($(this).hasClass('empty')) return false;
  221.             var item = $(this).data('d'),
  222.                 Nb = parseInt(item.count, 10);
  223.             itemsNb += Nb;
  224.             itemsSell += Nb * parseInt(item.price_sell, 10);
  225.             if (itemsXp != -1) itemsXp += Nb * parseInt(item.value, 10);
  226.         });
  227.  
  228.         var tooltip = 'You own <b>' + NbCommas(itemsNb) + '</b> ' + itemName + '.<br />'
  229.                     + (itemsXp == -1 ? '' : 'You can give a total of <b>' + NbCommas(itemsXp) + '</b> ' + itemUnit + '.<br />')
  230.                     + 'You can sell everything for <b>' + NbCommas(itemsSell) + '</b> <span class="imgMoney"></span>.';
  231.  
  232.         // save to localstorage
  233.         lsMarket.stocks[loc_class] = (loc_class == 'potion' || loc_class == 'gift') ? {'Nb':itemsNb, 'Xp':itemsXp} : {'Nb':itemsNb};
  234.         localStorage.setItem('lsMarket', JSON.stringify(lsMarket));
  235.  
  236.         // create or update tooltip
  237.         if (update === 0) {
  238.             loc.prepend('<span class="CustomTT"></span><div class="' + tt_class + '">' + tooltip + '</div>');
  239.         } else {
  240.             loc.children('.' + tt_class).html(tooltip);
  241.         }
  242.     }
  243.  
  244.     // -----------------
  245.     //     CSS RULES
  246.     // -----------------
  247.  
  248.     sheet.insertRule('#inventory .CustomTT {'
  249.                         + 'float: right;'
  250.                         + 'margin: 11px 1px 0 0;'
  251.                         + 'background-image: url("http://i.harem-battle.club/images/2017/09/13/FPE.png");'
  252.                         + 'background-size: 20px 20px;'
  253.                         + 'width: 20px;'
  254.                         + 'height: 20px; }');
  255.  
  256.     sheet.insertRule('#inventory .CustomTT:hover {'
  257.                         + 'cursor: help; }');
  258.  
  259.     sheet.insertRule('#inventory .CustomTT:hover + div {'
  260.                         + 'opacity: 1;'
  261.                         + 'visibility: visible; }');
  262.  
  263.     sheet.insertRule('#inventory .EquipmentsTooltip, #inventory .BoostersTooltip, #inventory .BooksTooltip, #inventory .GiftsTooltip {'
  264.                         + 'position: absolute;'
  265.                         + 'z-index: 99;'
  266.                         + 'width: 240px;'
  267.                         + 'border: 1px solid rgb(162, 195, 215);'
  268.                         + 'border-radius: 8px;'
  269.                         + 'box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.1);'
  270.                         + 'padding: 3px 7px 4px 7px;'
  271.                         + 'background-color: #F2F2F2;'
  272.                         + 'font: normal 10px/17px Tahoma, Helvetica, Arial, sans-serif;'
  273.                         + 'color: #057;'
  274.                         + 'opacity: 0;'
  275.                         + 'visibility: hidden;'
  276.                         + 'transition: opacity 400ms, visibility 400ms; }');
  277.  
  278.     sheet.insertRule('#inventory .EquipmentsTooltip, #inventory .BoostersTooltip {'
  279.                         + 'margin: -33px 0 0 210px;'
  280.                         + 'height: 43px; }');
  281.  
  282.     sheet.insertRule('#inventory .BooksTooltip, #inventory .GiftsTooltip {'
  283.                         + 'margin: -50px 0 0 210px;'
  284.                         + 'height: 60px; }');
  285.  
  286.     sheet.insertRule('#inventory .EquipmentsTooltip b, #inventory .BoostersTooltip b, #inventory .BooksTooltip b, #inventory .GiftsTooltip b {'
  287.                         + 'font-weight:bold; }');
  288.  
  289.     sheet.insertRule('#inventory .imgMoney {'
  290.                         + 'background-size: 12px 12px;'
  291.                         + 'background-repeat: no-repeat;'
  292.                         + 'width: 12px;'
  293.                         + 'height: 14px;'
  294.                         + 'vertical-align: text-bottom;'
  295.                         + 'background-image: url("http://i.harem-battle.club/images/2017/01/07/0Gsvn.png");'
  296.                         + 'display: inline-block; }');
  297. }
  298.  
  299.  
  300. /* =========
  301.      Harem
  302.    ========= */
  303.  
  304. function ModifyHarem() {
  305.     // initialize
  306.     var i = 0,
  307.         GirlId = '',
  308.         GirlName = '',
  309.         Anchor = '',
  310.         Specialty = [0, 0, 0], // [Hardcore, Charm, Know-how]
  311.         UnlockedSc = 0,
  312.         AvailableSc = 0,
  313.         IncHourly = 0,
  314.         IncCollect = 0,
  315.         HList = [],
  316.         Saffection = 0, // S= Stats tab
  317.         Smoney = 0,
  318.         Skobans = 0,
  319.         ScenesLink = '';
  320.  
  321.     var EvoReq = [];
  322.     EvoReq.push({ affection: 15, money: 3150, kobans: 30 });
  323.     EvoReq.push({ affection: 50, money: 6750, kobans: 90 });
  324.     EvoReq.push({ affection: 150, money: 18000, kobans: 150 });
  325.     EvoReq.push({ affection: 700, money: 135000, kobans: 240 });
  326.     EvoReq.push({ affection: 1750, money: 968000, kobans: 300 });
  327.  
  328.     // parse haremettes list
  329.     $('#harem_left').find('div[girl]').each( function(){
  330.         i++;
  331.  
  332.         GirlId = $(this).attr('girl');
  333.         GirlName = $(this).find('h4').text();
  334.         IncCollect += parseInt($(this).find('.sal').text(), 10);
  335.         HList.push({Id: GirlId, Order: i, Name: GirlName});
  336.  
  337.         // add anchor
  338.         $(this).attr('id', GirlName);
  339.         // is opened girl?
  340.         if ($(this).hasClass('opened')) Anchor = GirlName;
  341.  
  342.         // display: haremette number
  343.         $(this).find('h4').append('<div class="HaremetteNb">' + i + '</div>');
  344.     });
  345.     var HaremBottom = '<a href="#' + GirlName + '">Bottom</a>';
  346.  
  347.     // auto-scroll to anchor
  348.     location.hash = '#' + Anchor;
  349.  
  350.     // get haremettes stats & display wiki link
  351.     i = 0;
  352.     $('#harem_right').children('[girl]').each( function() {
  353.         // display: wiki link
  354.         $(this).append('<div class="WikiLink"><a href="http://harem-battle.club/wiki/Harem-Heroes/HH:' + HList[i].Name + '" target="_blank">Wiki</a></div>');
  355.         console.log(HList[i]);
  356.         i++;
  357.  
  358.         var j = 0,
  359.             Taffection = 0, // T= Total requirements (right tooltip)
  360.             Tmoney = 0,
  361.             Tkobans = 0,
  362.             FirstLockedScene = 1,
  363.             AffectionTT = 'She is your <b>' + i + '</b>th haremette. Her evolution costs are:<br />',
  364.             girl_quests = $(this).find('.girl_quests');
  365.  
  366.         // get stats: specialty
  367.         Spe = parseInt($(this).find('h3 > span').attr('carac'), 10) - 1;
  368.         Specialty[Spe]++;
  369.  
  370.         // get stats: hourly income
  371.         IncHourly += parseInt($(this).find('.salary').text(), 10);
  372.  
  373.         girl_quests.find('g').each( function() {
  374.             // prepare affection tooltip
  375.             var Raffection = EvoReq[j].affection * 417 * i, // R= Required for this star (right tooltip) // 417 price of 1 affection
  376.                 Rmoney =  EvoReq[j].money * i,
  377.                 Rkobans = EvoReq[j].kobans * i;
  378.             Taffection += Raffection;
  379.             Tmoney += Rmoney;
  380.             Tkobans += Rkobans;
  381.             j++;
  382.             AffectionTT += '<b>' + j + '</b><span class="imgStar"></span> : '
  383.                          + NbCommas(Raffection + Rmoney) + ' <span class="imgMoney"></span> = '
  384.                          + '' + NbCommas(Raffection) + ' <span class="imgMoney"></span> (aff) + '
  385.                          + '(' + NbCommas(Rmoney) + ' <span class="imgMoney"></span> (quest) or ' + NbCommas(Rkobans) + ' <span class="imgKobans"></span>)<br/>';
  386.  
  387.             // get stats: unlocked/available scenes & prepare scenes link
  388.             AvailableSc++;
  389.             ScenesLink += (ScenesLink === '') ? 'hh_scenes=' : ',';
  390.             var SceneHref = $(this).parent().attr('href');
  391.             if ($(this).hasClass('grey')) {
  392.                 if (FirstLockedScene === 0) {
  393.                     Saffection += Raffection;
  394.                     ScenesLink += '0';
  395.                 } else {
  396.                     FirstLockedScene = 0;
  397.                     var XpLeft = girl_quests.parent().children('.girl_exp_left');
  398.                     var isUpgradable = girl_quests.parent().children('.green_text_button');
  399.                     // girl has Xp left
  400.                     Saffection += (XpLeft.length) ? parseInt(XpLeft.text().match(/^.+: (.*)$/)[1].replace(',',''), 10) : 0;
  401.                     // girl is upgradable
  402.                     ScenesLink += (isUpgradable.length) ? '0.' + isUpgradable.attr('href').substr(7) : '0';
  403.                 }
  404.                 Smoney += Rmoney;
  405.                 Skobans += Rkobans;
  406.             } else {
  407.                 UnlockedSc++;
  408.                 ScenesLink += $(this).parent().attr('href').substr(7);
  409.             }
  410.         });
  411.  
  412.         // change scene links
  413.         girl_quests.children('a').each(function() {
  414.             var attr = $(this).attr('href');
  415.             if (typeof attr !== typeof undefined && attr !== false) {
  416.                 $(this).attr('href', attr + '?' + ScenesLink);
  417.             }
  418.         });
  419.         ScenesLink = '';
  420.  
  421.         AffectionTT += '<b>Total:</b> '
  422.                      + NbCommas(Taffection + Tmoney) + ' <span class="imgMoney"></span> = '
  423.                      + '' + NbCommas(Taffection) + ' <span class="imgMoney"></span> (aff) + '
  424.                      + '(' + NbCommas(Tmoney) + ' <span class="imgMoney"></span> (quest) or ' + NbCommas(Tkobans) + ' <span class="imgKobans"></span>)';
  425.  
  426.         // display: Affection costs tooltip
  427.         girl_quests.parent().children('h4').prepend('<span class="CustomTT"></span><div class="AffectionTooltip">' + AffectionTT + '</div>');
  428.     });
  429.  
  430.     // ### TAB: Quick List ###
  431.  
  432.     // order haremettes alphabetically
  433.     HList.sort(function(a, b) {
  434.         var textA = a.Name.toUpperCase(),
  435.             textB = b.Name.toUpperCase();
  436.         return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
  437.     });
  438.     // html quick list
  439.     var len = HList.length,
  440.         QListString = '<div class="QListContent"><span class="Title">Quick List:</span>';
  441.     for (i = 0; i < len; i++) {
  442.         QListString += '<br /><a f="ql_girl" girl="' + HList[i].Id + '" href="#' + HList[i].Name + '">' + HList[i].Name + '</a> (#' + HList[i].Order + ')';
  443.     }
  444.     QListString += '</div>';
  445.  
  446.     // ### TAB: Stats ###
  447.  
  448.     // Market stocks
  449.     try {
  450.         var lsMarket = JSON.parse(localStorage.getItem('lsMarket')),
  451.             d = new Date(lsMarket.restock.time);
  452.         console.log(lsMarket);
  453.  
  454.         // buyable stocks
  455.         if (new Date() > lsMarket.restock.time || Hero.infos.level > lsMarket.restock.herolvl) {
  456.             var RestockInfo = '> The <a href="../shop.html">Market</a> restocked since your last visit.';
  457.         } else {
  458.             var marketBookTxt = lsMarket.buyable.potion.Nb + ' book' + (lsMarket.buyable.potion.Nb > 1 ? 's' : '') + ' (' + NbCommas(lsMarket.buyable.potion.Xp) + ' Xp)',
  459.                 marketGiftTxt = lsMarket.buyable.gift.Nb + ' gift' + (lsMarket.buyable.gift.Nb > 1 ? 's' : '') + ' (' + NbCommas(lsMarket.buyable.gift.Xp) + ' Aff)',
  460.                 RestockInfo = '- ' + marketBookTxt + ' for ' + NbCommas(lsMarket.buyable.potion.Value) + ' <img src="http://i.harem-battle.club/images/2017/01/07/0Gsvn.png">'
  461.                             + '<br />- ' + marketGiftTxt + ' for ' + NbCommas(lsMarket.buyable.gift.Value) + ' <img src="http://i.harem-battle.club/images/2017/01/07/0Gsvn.png">'
  462.                             + '<br /><font style="color:gray;">Restock: ' + d.toLocaleString() + ' (or level ' + (Hero.infos.level+1) + ')</font>';
  463.         }
  464.  
  465.         // my stocks
  466.         var myArmorTxt = NbCommas(lsMarket.stocks.armor.Nb) + (lsMarket.stocks.armor.Nb > 99 ? '+ ' : ' ') + 'equipment' + (lsMarket.stocks.armor.Nb > 1 ? 's' : ''),
  467.             myBoosterTxt = NbCommas(lsMarket.stocks.booster.Nb) + ' booster' + (lsMarket.stocks.booster.Nb > 1 ? 's' : ''),
  468.             myBookTxt = NbCommas(lsMarket.stocks.potion.Nb) + ' book' + (lsMarket.stocks.potion.Nb > 1 ? 's' : '') + ' (' + NbCommas(lsMarket.stocks.potion.Xp) + ' Xp)',
  469.             myGiftTxt = NbCommas(lsMarket.stocks.gift.Nb) + ' gift' + (lsMarket.stocks.gift.Nb > 1 ? 's' : '') + ' (' + NbCommas(lsMarket.stocks.gift.Xp) + ' Aff)',
  470.             MarketStocks = '- ' + myArmorTxt + ', ' + myBoosterTxt
  471.                          + '<br />- ' + myBookTxt
  472.                          + '<br />- ' + myGiftTxt
  473.                          + '<span class="subTitle">Currently Buyable Stocks:</span>'
  474.                          + RestockInfo;
  475.     } catch(e) {
  476.         var MarketStocks = (lsAvailable == 'yes') ? '> Visit the <a href="../shop.html">Market</a> first.' : '> Your webbrowser is not compatible.';
  477.     }
  478.  
  479.     var StatsString = '<div class="StatsContent"><span class="Title">Harem Stats:</span>'
  480.                     + '<span class="subTitle" style="margin-top:-10px;">' + i + ' haremettes:</span>'
  481.                     + '- ' + Specialty[0] + ' Hardcore, ' + Specialty[1] + ' Charm, ' + Specialty[2] + ' Know-how'
  482.                     + '<br />- ' + UnlockedSc + '/' + AvailableSc + ' unlocked scenes'
  483.                     + '<span class="subTitle">Money incomes:</span>'
  484.                     + '~' + NbCommas(IncHourly) + ' <img src="http://i.harem-battle.club/images/2017/01/07/0Gsvn.png"> per hour'
  485.                     + '<br />' + NbCommas(IncCollect) + ' <img src="http://i.harem-battle.club/images/2017/01/07/0Gsvn.png"> when all collectable'
  486.                     + '<span class="subTitle">Required to unlock all locked scenes:</span>'
  487.                     + NbCommas(Saffection + Smoney) + ' <img src="http://i.harem-battle.club/images/2017/01/07/0Gsvn.png">: '
  488.                     + '<br/> - ' + NbCommas(Saffection) + ' <img src="http://i.harem-battle.club/images/2017/01/07/0Gsvn.png"> for affections '
  489.                     + '<br/> - ' + NbCommas(Smoney) + ' <img src="http://i.harem-battle.club/images/2017/01/07/0Gsvn.png"> for quests'
  490.                     + '<span class="subTitle">My Stocks:</span>'
  491.                     + MarketStocks
  492.                     + '</div>';
  493.  
  494.     // add custom bar buttons/links & quick list div & stats div
  495.     $('#harem_left').append('<div id="CustomBar">'
  496.                           + '<img f="list" src="http://i.harem-battle.club/images/2017/09/10/FRW.png">'
  497.                           + '<img f="stats" src="http://i.harem-battle.club/images/2017/09/11/FRh.png">'
  498.                           + '<div class="TopBottomLinks"><a href="#Bunny">Top</a>&nbsp;&nbsp;|&nbsp;&nbsp;' + HaremBottom + '</div>'
  499.                           + '</div>'
  500.                           + '<div id="TabsContainer">' + QListString + StatsString + '</div>');
  501.  
  502.     // cache
  503.     TabsContainer = $('#TabsContainer');
  504.     QList = TabsContainer.children('.QListContent');
  505.     Stats = TabsContainer.children('.StatsContent');
  506.  
  507.     // catch clicks
  508.     $('body').click(function(e) {
  509.         var clickOn = e.target.getAttribute('f');
  510.         switch (clickOn) {
  511.             // on quick list button
  512.             case 'list':
  513.                 toggleTabs(QList, Stats);
  514.                 break;
  515.             // on stats button
  516.             case 'stats':
  517.                 toggleTabs(Stats, QList);
  518.                 break;
  519.             // on a girl in quick list
  520.             case 'ql_girl':
  521.                 var clickedGirl = e.target.getAttribute('girl');
  522.                 $('#harem_left').find('[girl=' + clickedGirl + ']').triggerHandler('click');
  523.                 break;
  524.             // somewhere else except custom containers
  525.             default:
  526.                 var clickedContainer = $(e.target).closest('[id]').attr('id');
  527.                 if (clickedContainer == 'TabsContainer') return;
  528.                 TabsContainer.fadeOut(400);
  529.         }
  530.     });
  531.  
  532.     // tabs switching animations
  533.     function toggleTabs(tabIn, tabOut) {
  534.         if (TabsContainer.css('display') == 'block') {
  535.             if (tabOut.css('display') == 'block') {
  536.                 tabOut.fadeOut(200);
  537.                 setTimeout( function(){ tabIn.fadeIn(300); }, 205 );
  538.             } else {
  539.                 TabsContainer.fadeOut(400);
  540.             }
  541.         } else {
  542.             tabOut.toggle(false);
  543.             tabIn.toggle(true);
  544.             TabsContainer.fadeIn(400);
  545.         }
  546.     }
  547.  
  548.     // -----------------
  549.     //     CSS RULES
  550.     // -----------------
  551.  
  552.     sheet.insertRule('#harem_left .HaremetteNb {'
  553.                         + 'float: right;'
  554.                         + 'line-height: 14px;'
  555.                         + 'font-size: 12px; }');
  556.  
  557.     sheet.insertRule('#CustomBar {'
  558.                         + 'position: absolute;'
  559.                         + 'z-index: 99;'
  560.                         + 'width: 100%;'
  561.                         + 'padding: 3px 10px 0 3px;'
  562.                         + 'font: bold 10px Tahoma, Helvetica, Arial, sans-serif; }');
  563.  
  564.     sheet.insertRule('#CustomBar img {'
  565.                         + 'width: 20px;'
  566.                         + 'height: 20px;'
  567.                         + 'margin-right: 3px;'
  568.                         + 'opacity: 0.5; }');
  569.  
  570.     sheet.insertRule('#CustomBar img:hover {'
  571.                         + 'opacity: 1;'
  572.                         + 'cursor: pointer; }');
  573.  
  574.     sheet.insertRule('#CustomBar .TopBottomLinks {'
  575.                         + 'float: right;'
  576.                         + 'margin-top: 2px; }');
  577.  
  578.     sheet.insertRule('#CustomBar a, #TabsContainer a, #harem_right .WikiLink a {'
  579.                         + 'color: #057;'
  580.                         + 'text-decoration: none; }');
  581.  
  582.     sheet.insertRule('#CustomBar a:hover, #TabsContainer a:hover, #harem_right .WikiLink a:hover {'
  583.                         + 'color: #B14;'
  584.                         + 'text-decoration: underline; }');
  585.  
  586.     sheet.insertRule('#TabsContainer {'
  587.                         + 'position: absolute;'
  588.                         + 'z-index: 99;'
  589.                         + 'margin: -270px 0 0 -1px;'
  590.                         + 'width: 240px;'
  591.                         + 'height: 270px;'
  592.                         + 'overflow-y: scroll;'
  593.                         + 'border: 1px solid rgb(156, 182, 213);'
  594.                         + 'box-shadow: 1px -1px 1px 0px rgba(0,0,0,0.3);'
  595.                         + 'font: normal 10px/16px Tahoma, Helvetica, Arial, sans-serif;'
  596.                         + 'color: #000000;'
  597.                         + 'background-color: #ffffff;'
  598.                         + 'display: none; }');
  599.  
  600.     sheet.insertRule('#TabsContainer > div {'
  601.                         + 'padding: 1px 0 8px 10px; }');
  602.  
  603.     sheet.insertRule('#TabsContainer .Title {'
  604.                         + 'margin-left: -5px;'
  605.                         + 'font: bold 12px/22px Tahoma, Helvetica, Arial, sans-serif;'
  606.                         + 'color: #B14; }');
  607.  
  608.     sheet.insertRule('#TabsContainer .subTitle {'
  609.                         + 'padding-top: 10px;;'
  610.                         + 'font-weight: bold;'
  611.                         + 'display: block; }');
  612.  
  613.     sheet.insertRule('#TabsContainer img {'
  614.                         + 'width: 14px;'
  615.                         + 'height: 14px;'
  616.                         + 'vertical-align: text-bottom; }');
  617.  
  618.     sheet.insertRule('#harem_right .CustomTT {'
  619.                         + 'float: right;'
  620.                         + 'margin-left: -25px;'
  621.                         + 'background-image: url("http://i.harem-battle.club/images/2017/09/13/FPE.png");'
  622.                         + 'background-size: 18px 18px;'
  623.                         + 'width: 18px;'
  624.                         + 'height: 18px; }');
  625.  
  626.     sheet.insertRule('#harem_right .CustomTT:hover {'
  627.                         + 'cursor: help; }');
  628.  
  629.     sheet.insertRule('#harem_right .CustomTT:hover + div {'
  630.                         + 'opacity: 1;'
  631.                         + 'visibility: visible; }');
  632.  
  633.     sheet.insertRule('#harem_right .AffectionTooltip {'
  634.                         + 'position: absolute;'
  635.                         + 'z-index: 99;'
  636.                         + 'margin: -130px 0 0 -38px;'
  637.                         + 'width: 390px;'
  638.                         + 'height: 127px;'
  639.                         + 'border: 1px solid rgb(162, 195, 215);'
  640.                         + 'border-radius: 8px;'
  641.                         + 'box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.1);'
  642.                         + 'padding: 3px 7px 4px 7px;'
  643.                         + 'background-color: #F2F2F2;'
  644.                         + 'font: normal 10px/17px Tahoma, Helvetica, Arial, sans-serif;;'
  645.                         + 'text-align: left;'
  646.                         + 'opacity: 0;'
  647.                         + 'visibility: hidden;'
  648.                         + 'transition: opacity 400ms, visibility 400ms; }');
  649.  
  650.     sheet.insertRule('#harem_right .AffectionTooltip b {'
  651.                         + 'font-weight: bold; }');
  652.  
  653.     sheet.insertRule('#harem_right .WikiLink {'
  654.                         + 'float: right;'
  655.                         + 'margin: -13px 7px 0 0;'
  656.                         + 'font-size: 12px; }');
  657.  
  658.     sheet.insertRule('#harem_right .imgStar, #harem_right .imgMoney, #harem_right .imgKobans {'
  659.                         + 'background-size: 10px 10px;'
  660.                         + 'background-repeat: no-repeat;'
  661.                         + 'width: 10px;'
  662.                         + 'height: 14px;'
  663.                         + 'display: inline-block; }');
  664.  
  665.     sheet.insertRule('#harem_right .imgStar {'
  666.                         + 'background-image: url("http://i.harem-battle.club/images/2016/12/29/R9HWCKEtD.png"); }');
  667.  
  668.     sheet.insertRule('#harem_right .imgMoney {'
  669.                         + 'background-image: url("http://i.harem-battle.club/images/2017/01/07/0Gsvn.png"); }');
  670.  
  671.     sheet.insertRule('#harem_right .imgKobans {'
  672.                         + 'background-image: url("http://i.harem-battle.club/images/2016/08/30/gNUo3XdY.png"); }');
  673. }
  674.  
  675.  
  676. /* ==========
  677.      Scenes
  678.    ========== */
  679.  
  680. function ModifyScenes() {
  681.     // parse GET hh_scenes variable
  682.     var currentScene = CurrentPage.substr(7),
  683.         hh_scenesParams = new URL(window.location.href).searchParams.get('hh_scenes'),
  684.         hh_scenes = hh_scenesParams.split(','),
  685.         len = hh_scenes.length;
  686.  
  687.     // no scenes, less than 3 or more than 5 (human manipulation)
  688.     if (!len || len < 3 || len > 5) {
  689.         return false;
  690.     } else {
  691.         var ScenesNavigate = '<div class="Scenes" style="display:block;">Navigate:<br/>',
  692.             SceneLink = '';
  693.  
  694.         for (var i = 0; i < len; i++ ) {
  695.             // string format certification
  696.             if (/^(0\.)?[0-9]{1,5}$/.test(hh_scenes[i]) === true) {
  697.                 if (hh_scenes[i] == currentScene) {
  698.                     SceneLink = '<span class="current">current</span>';
  699.                 } else if (hh_scenes[i] == '0') {
  700.                     SceneLink = '<span class="locked">locked</span>';
  701.                 } else if (parseInt(hh_scenes[i], 10) < 1) {
  702.                     SceneLink = '<a href="/quest/' + hh_scenes[i].substr(2) + '">unlock it!</a>';
  703.                 } else {
  704.                     SceneLink = '<a href="/quest/' + hh_scenes[i] + '?hh_scenes=' + hh_scenesParams + '">scene</a>';
  705.                 }
  706.                 ScenesNavigate += (i+1) + '<span class="imgStar"></span> ' + SceneLink + '<br />';
  707.             }
  708.             // string error: doesn't match (human manipulation)
  709.             else return false;
  710.         }
  711.         ScenesNavigate += '<span class="backToHarem">< <a href="' + $('#breadcrumbs').children('a').eq(2).attr('href') + '">Harem</a></span></div>';
  712.  
  713.         // insert navigate interface
  714.         $('#controls').append(ScenesNavigate);
  715.     }
  716.  
  717.     // -----------------
  718.     //     CSS RULES
  719.     // -----------------
  720.  
  721.     sheet.insertRule('#controls .Scenes {'
  722.                         + 'height:200px;'
  723.                         + 'box-shadow: 3px 3px 0px 0px rgba(0,0,0,0.3);'
  724.                         + 'background-color:#000000;'
  725.                         + 'background: linear-gradient(to bottom, rgba(196,3,35,1) 0%,rgba(132,2,30,1) 51%,rgba(79,0,14,1) 100%);'
  726.                         + 'text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.4);'
  727.                         + 'display: block !important; }');
  728.  
  729.     sheet.insertRule('#controls .current {'
  730.                         + 'color: rgb(251, 255, 108); }');
  731.  
  732.     sheet.insertRule('#controls .locked {'
  733.                         + 'color: rgb(150, 99, 99); }');
  734.  
  735.     sheet.insertRule('#controls .Scenes a {'
  736.                         + 'color: rgb(233, 142, 228);'
  737.                         + 'text-decoration: none; }');
  738.  
  739.     sheet.insertRule('#controls .Scenes a:hover {'
  740.                         + 'color: rgb(254, 202, 255);'
  741.                         + 'text-decoration: underline; }');
  742.  
  743.     sheet.insertRule('#controls .backToHarem {'
  744.                         + 'position: absolute;'
  745.                         + 'bottom: 0;'
  746.                         + 'left: 0;'
  747.                         + 'width: 100%; }');
  748.  
  749.     sheet.insertRule('#controls .imgStar {'
  750.                         + 'background-image: url("http://i.harem-battle.club/images/2016/12/29/R9HWCKEtD.png");'
  751.                         + 'background-size: 10px 10px;'
  752.                         + 'background-repeat: no-repeat;'
  753.                         + 'width: 10px;'
  754.                         + 'height: 18px;'
  755.                         + 'display: inline-block; }');
  756. }
  757.  
  758. // is localstorage available?
  759. function lsTest() {
  760.     try {
  761.         localStorage.setItem('test', 'test');
  762.         localStorage.removeItem('test');
  763.         return true;
  764.     } catch(e) {
  765.         return false;
  766.     }
  767. }
  768.  
  769. // adds thousands commas
  770. function NbCommas(x) {
  771.     return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  772. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement