F95Zone Developer Search

Adds a button to search for the developer on f95zone

Verze ze dne 29. 05. 2024. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         F95Zone Developer Search
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a button to search for the developer on f95zone
// @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 the search button
    function createSearchButton(developerName) {
        const button = document.createElement('button');
        button.innerText = 'Search Developer';
        button.style.marginLeft = '10px';
        button.style.cursor = 'pointer';
        button.onclick = function() {
            const searchUrl = `https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/creator=${developerName}`;
            window.open(searchUrl, '_blank');
        };
        return button;
    }

    // Find the title element
    const titleElement = document.querySelector('.p-title h1.p-title-value');
    if (titleElement) {
        // Extract the developer's name
        const titleText = titleElement.innerText;
        const developerMatch = titleText.match(/\[([^\]]+)\]$/);
        if (developerMatch) {
            const developerName = developerMatch[1];
            const searchButton = createSearchButton(developerName);

            // Append the button next to the title
            titleElement.appendChild(searchButton);
        }
    }
})();