Greasy Fork is available in English.

[GC | Beta Testing] - SSW: Savvy Shop Wiz

Blocked users can be synced but do not actually change anything in the SW results yet.

// ==UserScript==
// @name        [GC | Beta Testing] - SSW: Savvy Shop Wiz
// @namespace   https://greasyfork.org/en/users/1225524-kaitlin
// @match       https://www.grundos.cafe/block/
// @match				https://www.grundos.cafe/market/wizard/
// @match				https://www.grundos.cafe/guilds/guild/*/members/
// @require  	  https://cdn.jsdelivr.net/npm/jquery@3.6.4/dist/jquery.min.js
// @grant				GM_getValue
// @grant     	GM_setValue
// @grant				GM_listValues
// @grant				GM_addStyle
// @license     MIT
// @version     1.3
// @author      Cupkait
// @icon        https://i.imgur.com/4Hm2e6z.png
// @require			https://update.greasyfork.org/scripts/488092/1332297/%5BGC%20%7C%20Library%5D%20Organize%20SW%20Results.js
// @require 		https://update.greasyfork.org/scripts/487361/1327714/%5BGC%20%7C%20Library%5D%20-%20SSW%3A%20Savvy%20Shop%20Wiz.js
// @description	 Blocked users can be synced but do not actually change anything in the SW results yet.
// ==/UserScript==

createSSWMenu();
let wizList = $('.sw_results div');


if ((window.location.href ===
	'https://www.grundos.cafe/market/wizard/') && (wizList.length > 0)) {
	OrganizeShopWizResults();
}






// Button actions/functions
function removeUsersManually() {
	var userInput = prompt(
		'Which username would you like to remove from your list? Enter one username then click OK.'
	);

	if (userInput !== null && userInput.trim() !== '') {
		// Find and remove the username from the friendList array (case insensitive)
		var index = friendList.findIndex(name => name
			.toLowerCase() === userInput.trim().toLowerCase());
		if (index !== -1) {
			friendList.splice(index, 1);
			GM_setValue('friendList', friendList);
			console.log('Removed', userInput.trim(),
				'from the friend list.');
		} else {
			console.log(userInput.trim(),
				'not found in the friend list.');
		}

		if (window.location.href ===
			'https://www.grundos.cafe/market/wizard/') {

			if (confirm(
					'Do you want to reload the page to see the updated results?'
				)) {
				location.reload();
			}
		}

	} else {
		console.log('No username entered. Operation canceled.');
	}
}
$(ManualRemove).on('click', removeUsersManually);

async function syncFriendsList() {
	try {
		const response = await fetch(
			'https://www.grundos.cafe/neofriends/');
		const html = await response.text();
		const doc = new DOMParser().parseFromString(html,
			'text/html');
		const uniqueUsernames = new Set();

		doc.querySelectorAll(
				'div.market_grid [href*="/userlookup/?user="]')
			.forEach(function (element) {
				uniqueUsernames.add(element.getAttribute(
					'href').split('=')[1]);
			});

		console.log("Friends List Synced");
		return Array.from(uniqueUsernames);
	} catch (error) {
		console.error('Error fetching and extracting usernames:',
			error);
		return [];
	}

}
$(SyncFriends).on('click', async function () {
	const usernames = await syncFriendsList();
	friendList = usernames;
	GM_setValue('friendList', friendList);
	console.log('Synced usernames:', usernames);
});

function syncBlockedList() {
	if (window.location.href === 'https://www.grundos.cafe/block/') {
		// Retrieve the blockList array
		const blockList = $('.block_list').find('span').map(
			function () {
				return $(this).text();
			}).get();
		GM_setValue('blockList', blockList);
		console.log('blockList stored:', blockList);
	} else {
		// Display a confirmation dialog
		if (confirm(
				'You can only do this from the Blocked Users page. Want to open it in a new tab?'
			)) {
			// If the user clicks "OK" (true), open the page in a new tab
			window.open('https://www.grundos.cafe/block/', '_blank');
		} else {
			// If the user clicks "Cancel" (false), log a message
			console.log('User declined. No blocked sync occured.');
		}
	}
}
$(SyncBlocked).on('click', syncBlockedList);

function syncGuildMembers() {
    if (/^https:\/\/www\.grundos\.cafe\/guilds\/guild\/.+\/members\//.test(window.location.href)) {
const userName = /user=(.*?)"/g.exec(document.body.innerHTML)[1];
const guildIdentifier = window.location.href.match(/guild\/([^\/-]+)/)?.[1];
const guildName = $('.guild-header strong').eq(0).text();
const guildID = "guildID_" + guildIdentifier;

const guildMembers = [...new Set($('div.member-grid [href*="/userlookup/?user="]')
    .map(function() {
        return $(this).attr('href').split('=')[1];
    })
    .filter(function(guildMember) {

        return guildMember !== userName;

    }))];


var guildsList = GM_getValue('guildsList', {});

guildsList[guildID] = {
    'guildName': guildName,
    'guildMembers': guildMembers
};

GM_setValue('guildsList', guildsList);

    } else {
        if (confirm('You can only do this from the Guild Members page. Want to open it in a new tab?')) {
            window.open('https://www.grundos.cafe/guilds/', '_blank');
        } else {
            console.log('User declined. No action occurred.');
        }
    }
}
$(SyncGuild).on('click', syncGuildMembers);





// Add custom CSS styles to the webpage
GM_addStyle(`
    #sswmenu {
        display: none;
        border-radius: 15px 15px 15px 0px;
        border-bottom: 3px solid;
        position: absolute;
        width: 250px;
        height: 250px;
        bottom: 0%;
        left: 100%;
        margin: -3px;
        padding: 10px;
        background-color: #d2d0cc;
        box-shadow: 5px 0 5px rgba(0, 0, 0, 0.5);
    }
    #sswcontainer {
        position: relative;
        border-bottom: 3px solid;
        padding: 5px 10px 5px 0px;
        height: 30px;
        width: 100%;
        top: 00%;
        left: 0px;
        background-color: #d2d0cc;
        box-shadow: 5px 0 5px rgba(0, 0, 0, 0.5);
    }
    #sswsettings {
        position: relative;
        font-size: 16px;
        font-weight: bold;
        font-family: courier;
        border-radius: 5px;
        padding: 5px;
        width: 100%;
        height: auto;
        border: 1px solid rgb(204, 204, 204);
        cursor: pointer;
        background-color: lightgray;
    }
    #menubutton {
        height: 35px;
        width: 90%;
        margin: 5px;
    }
    /* Styling for specific elements */
    .data.sw_guild {
        order: -1;

    }
    .data.sw_friend {
        order: -1;
    }
		.data.sw_mine {
        order: -2;
    }


    .data.sw_block {
	background-color:#bcb6b6f7 !important;
	opacity:30%;
}
	.sw_block:hover {
	opacity:100%
}
`);