Last active
March 15, 2021 04:34
-
-
Save rooftopchicken/c2b9ae902a658f4ee534d5313d5b0cde to your computer and use it in GitHub Desktop.
Links to every page of the inventory while: filling the Serpent's Pot and using certain inventory items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name FV - full pagination | |
| // @version 0.5 | |
| // @description Adds links to every page when filling the pot and using certain inventory items. | |
| // @author msjanny (#7302) | |
| // @match https://www.furvilla.com/serpent/pot* | |
| // @match https://www.furvilla.com/inventory* | |
| // @grant GM_setValue | |
| // @grant GM_getValue | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| /* globals $:false */ | |
| function itemModalLoaded() { | |
| if(! $("#stack-form .btn").length) { | |
| setTimeout ( function() { | |
| itemModalLoaded(); | |
| }, 300); | |
| } | |
| else { | |
| $(".btn:contains('Use')").click(function() { | |
| loadScripts(); | |
| }); | |
| } | |
| } | |
| function loadScripts() { | |
| //check every 300ms if pagination has loaded before continuing | |
| // (up to 10 times) | |
| if(! $(".modal .pagination").length) { | |
| setTimeout ( function() { | |
| loadScripts(); | |
| }, 300); | |
| } | |
| else { | |
| $(".modal .pagination a").click(function() { | |
| GM_setValue("pagenum", $(this).attr('href').match(/\d+$/g)[0]); | |
| loadScripts(); | |
| }); | |
| fullPagination(); | |
| } | |
| } | |
| function fullPagination() { | |
| let active = $(".modal .pagination li").index($(".active").eq(0)); | |
| let url = $(".modal .pagination a").eq(0).attr("href").replace(/\d+$/g, ''); | |
| let pagenum = GM_getValue("pagenum", ""); | |
| if (pagenum && parseInt(pagenum) <= parseInt($(".modal .pagination").eq(0).find('li').eq(-2).text()) && parseInt(pagenum) != parseInt($(".modal .pagination .active").eq(0).text())) { | |
| if ($(".inventory-block-scrapping").length) { //scrapping | |
| loadInventoryBlockScrapping($(".inventory-block-scrapping"), url + pagenum); | |
| } | |
| else if ($(".inventory-block").length) { | |
| loadInventoryBlock($(".inventory-block"), url + pagenum); | |
| } | |
| else { //pot | |
| loadInventory(url + pagenum); | |
| } | |
| loadScripts(); | |
| } | |
| //for each ellipses | |
| $(".disabled:contains('...')", $(".modal .pagination").eq(0)).each(function(idx) { | |
| var pos = $(".modal .pagination li").index($(this)); | |
| var minPage = parseInt($(".modal .pagination li").eq(pos - 1).text()); | |
| var maxPage = parseInt($(".modal .pagination li").eq(pos + 1).text()); | |
| //add links | |
| for (var i = maxPage - 1; i > minPage; i--) { | |
| //create new link | |
| var a = $(`<a href="${url}${i}">${i}</a>`); | |
| a.click(function(e) { | |
| e.preventDefault(); | |
| GM_setValue("pagenum", $(this).attr('href').match(/\d+$/g)[0]); | |
| if ($(".inventory-block-scrapping").length) { //scrapping | |
| loadInventoryBlockScrapping($(".inventory-block-scrapping"), $(this).attr('href')); | |
| } | |
| else if ($(".inventory-block").length) { | |
| loadInventoryBlock($(".inventory-block"), $(this).attr('href')); | |
| } | |
| else { //pot | |
| loadInventory($(this).attr('href')); | |
| } | |
| loadScripts(); | |
| }); | |
| //add link | |
| $(this).after($("<li>").append(a)); | |
| $(".disabled:contains('...')", $(".modal .pagination").eq(1)).eq(idx).after($("<li>").append(a.clone(true))); | |
| } | |
| }); | |
| $(".disabled:contains('...')").remove(); | |
| } | |
| $(document).ready(function(){ | |
| //scrapping, pot | |
| $('.btn[data-url*="scrap/"], .items-btn, .brew-a, #stack-form .btn:contains("Use")').click(function() { | |
| loadScripts(); | |
| }); | |
| //inventory (oh dear) | |
| $(".show-inventory-actions").click(function() { | |
| itemModalLoaded(); | |
| }); | |
| }); | |
| })(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment