F95Zone Search Buttons for Steam

Adds buttons to search for the current game on F95Zone and its forums. Also autofills and submits the search form on the F95Zone forums search page by clicking the search button.

Από την 06/05/2024. Δείτε την τελευταία έκδοση.

// ==UserScript==
// @name         F95Zone Search Buttons for Steam
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Adds buttons to search for the current game on F95Zone and its forums. Also autofills and submits the search form on the F95Zone forums search page by clicking the search button.
// @author       FunkyJustin
// @match        https://store.steampowered.com/app/*
// @grant        none
// @license MIT

// ==/UserScript==

(function() {
    'use strict';

    function createF95ZoneButton() {
        const gameTitle = document.querySelector('.apphub_AppName').innerText.trim();
        const f95zoneGameLink = `https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/search=${encodeURIComponent(gameTitle)}`;
        const f95zoneForumLink = `https://f95zone.to/search/?q=${encodeURIComponent(gameTitle)}&t=post&c[child_nodes]=1&c[nodes][0]=2&c[title_only]=1&o=relevance`;

        const gameButton = createButton('Search on F95Zone', f95zoneGameLink);
        const forumButton = createButton('Search on F95Zone Forums', f95zoneForumLink);

        const container = document.querySelector('.apphub_OtherSiteInfo');
        container.appendChild(gameButton);
        container.appendChild(forumButton);

        // Click the search button on F95Zone forums page after loading
        if (window.location.href === f95zoneForumLink) {
            window.onload = function() {
                setTimeout(function() {
                    const searchField = document.querySelector('.input[name="keywords"]');
                    if (searchField) {
                        searchField.value = gameTitle;
                        searchField.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
                    }
                }, 1000); // 1 second delay before pressing Enter
            };
        }
    }

    function createButton(text, link) {
        const button = document.createElement('a');
        button.innerText = text;
        button.href = link;
        button.target = '_blank';
        button.style.display = 'inline-block'; // Change display to inline-block
        button.style.marginRight = '10px'; // Add margin between buttons
        button.style.color = '#fff';
        button.style.backgroundColor = '#009688';
        button.style.padding = '10px';
        button.style.borderRadius = '5px';
        button.style.textDecoration = 'none';
        button.style.cursor = 'pointer';

        return button;
    }

    // Wait for the game details to load before creating the button
    window.addEventListener('load', createF95ZoneButton);
})();