Greasy Fork is available in English.

[GC | BETA] - Enhanced UB Search Helper

Adds enhanced search features to SW and TP to make the navigation of searching and browsing expensive items easier.

// ==UserScript==
// @name        [GC | BETA] - Enhanced UB Search Helper
// @namespace   https://greasyfork.org/en/users/1225524-kaitlin
// @match       https://www.grundos.cafe/market/wizard/*
// @match       https://www.grundos.cafe/island/tradingpost/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @license     MIT
// @version     .1
// @author      Cupkait
// @description Adds enhanced search features to SW and TP to make the navigation of searching and browsing expensive items easier.
// ==/UserScript==

const wizText = $("#page_content > main");
const pageUrl = window.location.href;

//HANDLE SHOP WIZ SEARCHES
if (pageUrl.includes("grundos.cafe/market/wizard/")) {
    const noneBuyable = wizText.find("p.center");
    var itemSearched = $(wizText).find('strong').eq(0).text().split('... ')[1].trim();

    console.log(itemSearched);

    if (noneBuyable.text().includes("I did not find anything")) {
        noneBuyable.html('Oh dear, no one is selling one of these... <img src="https://grundoscafe.b-cdn.net/boards/emoticons/holler.gif"><br>Try one of these locations, perhaps?<div id="altlinks"><div class="button" id="tp"><a href="https://www.grundos.cafe/island/tradingpost/browse/?query=' + itemSearched + '&autosubmit=1">trading post</a></div> <div class="button" id="ah"><a href="https://www.grundos.cafe/auctions/genie/?type=process_genie&query=' + itemSearched + '&criteria=exact">auction house</a></div></div>');
        console.log("Item is not available on the Shop Wizard.");
    } else {
        console.log("Shop Wizard search successfully returned results.")
    }
};

//HANDLE TRADING POST SEARCHES
if (pageUrl.includes("grundos.cafe/island/tradingpost"))
{
    (function() {
    var autosubmitParam = '&autosubmit=1';
 
    $('document').ready( function() {
        $('a[href*="tradingpost/browse/?query"]').click(function() {
            const shouldSubmit = confirm("Submit trading post query?");
            if (shouldSubmit) {
                window.open($(this).attr('href') + autosubmitParam);
                return false;
            }
        } );
 
 
        const shouldAutosearch = new RegExp(`.*tradingpost\/browse.*query.*${autosubmitParam}.*`).test(window.location.href);
 
        if (shouldAutosearch) {
            var queryExists = $('input[name="query"]').eq(1).val().length > 0;
            var isNewSearch = $('.browse').length == 0
            if (queryExists && isNewSearch) {
                $('input[value="Find those lots!"]').click();
            }
        }
    });
})();
    console.log("Trading Post")
    $('.trade-item').each(function () {
                var itemName = $(this).find('span').eq(0).text();
                            console.log(itemName)

                $(this).after('<div id="tplinks"><div class="tpsearch" id="tp"><a alt="Shop Wizard" href="https://www.grundos.cafe/market/wizard/?query=' + itemName + '&autosubmit=1"><i class="material-icons">store</i></a></div><div class="tpsearch" id="tp"><a alt="Trading Post" href="https://www.grundos.cafe/island/tradingpost/browse/?query='+ itemName + '&autosubmit=1"><i class="material-icons">swap_horiz</i></a></div> <div class="tpsearch" id="ah"><a alt="Auction House" href="https://www.grundos.cafe/auctions/genie/?type=process_genie&query=' + itemName + '&criteria=exact"><i class="material-icons">gavel</i></a></div><div class="tpsearch" id="tp"><a alt="Site Search" href="https://www.grundos.cafe/search/items/?item_name=' + itemName + '"><i class="material-icons">search</i></a></div></div>');


            });
}



const style = document.createElement('style');
style.innerHTML = `

@import url(https://fonts.googleapis.com/icon?family=Material+Icons);
.material-icons {
    
}

#altlinks {
	display:flex;
	justify-content:center;
	padding:10px;
}
#tplinks {
	display:flex;
	justify-content:right;
	padding:0px;
    margin:0px;
}
.tpsearch {
    padding: 0 5px 0 5px;
}
.big-gap {
    row-gap:0px !important;
}
.tpsearch a, .tpsearch:hover a{
    color:black !important;
    font-decoration:none;
    font-weight:normal;
    padding: 0 5px 0 5px;
}

.button a, .button:hover a {
    font-weight:normal !important;
    color:black !important;}

.button {
	padding:5px;
	margin:10px;
	font-family:heffaklump;
	font-size:28px;
	border:1px solid black;
	box-shadow:5px 5px 5px #00000078;
	background-color:#f5f5f575;
	border-radius:50px;
}
    `;
document.head.appendChild(style);