F95Zone Developer and Game Search on Steam

Adds buttons to search for the developer on f95zone and the game title on Steam

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         F95Zone Developer and Game Search on Steam
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Adds buttons to search for the developer on f95zone and the game title on Steam
// @author       FunkyJustin
// @license      MIT
// @match        https://f95zone.to/threads/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=f95zone.to
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to create a search button
    function createSearchButton(buttonText, searchUrl) {
        const button = document.createElement('button');
        button.innerText = buttonText;
        button.style.marginLeft = '10px';
        button.style.cursor = 'pointer';

        // Styling to match the website's button style
        button.style.padding = '5px 10px';
        button.style.fontSize = '14px';
        button.style.color = '#FFFFFF';
        button.style.backgroundColor = '#0073e6';
        button.style.border = 'none';
        button.style.borderRadius = '3px';
        button.style.display = 'inline-block';
        button.style.textAlign = 'center';

        // Hover effect
        button.onmouseover = function() {
            button.style.backgroundColor = '#005bb5';
        };
        button.onmouseout = function() {
            button.style.backgroundColor = '#0073e6';
        };

        button.onclick = function() {
            window.open(searchUrl, '_blank');
        };
        return button;
    }

    // Find the title element
    const titleElement = document.querySelector('.p-title h1.p-title-value');
    if (titleElement) {
        // Extract the full title text
        const titleText = titleElement.innerText;

        // Extract the developer's name
        const developerMatch = titleText.match(/\[([^\]]+)\]$/);
        if (developerMatch) {
            const developerName = developerMatch[1];
            const developerSearchUrl = `https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/creator=${developerName}`;
            const developerSearchButton = createSearchButton('Search Developer', developerSearchUrl);

            // Append the developer search button next to the title
            titleElement.appendChild(developerSearchButton);
        }

        // Remove labels (VN, Others, Completed, etc.)
        const cleanedTitleText = titleText.replace(/\[.*?\]/g, '').trim();

        // Extract the game title
        const gameTitleMatch = cleanedTitleText.match(/^(.*?)\s*$/);
        if (gameTitleMatch) {
            const gameTitle = gameTitleMatch[1].trim().replace(/\s+/g, '+');
            const gameSearchUrl = `https://store.steampowered.com/search/?term=${gameTitle}`;
            const gameSearchButton = createSearchButton('Search Game on Steam', gameSearchUrl);

            // Append the game search button next to the developer search button
            titleElement.appendChild(gameSearchButton);
        }
    }
})();