F95Zone Search Buttons for Steam

Adds buttons to search for the Steam game on F95Zone and its forums.

Tính đến 26-03-2024. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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

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

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

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         F95Zone Search Buttons for Steam
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Adds buttons to search for the Steam game on F95Zone and its forums.
// @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)}`;

        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);
    }

    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);

    // Listen for clicks on the F95Zone Forums button
    document.addEventListener('click', function(event) {
        if (event.target.textContent === 'Search on F95Zone Forums') {
            event.preventDefault();
            const gameTitle = document.querySelector('.apphub_AppName').innerText.trim();
            const f95zoneForumLink = `https://f95zone.to/search/?q=${encodeURIComponent(gameTitle)}`;
            window.location.href = f95zoneForumLink;
        }
    });
})();