F95Zone Search Buttons for DLsite

Adds buttons to search for the current game, circle, and product ID on F95Zone and its forums from DLsite. Also autofills and submits the search form on the F95Zone forums search page by clicking the search button.

Από την 06/06/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 Search Buttons for DLsite
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Adds buttons to search for the current game, circle, and product ID on F95Zone and its forums from DLsite. Also autofills and submits the search form on the F95Zone forums search page by clicking the search button.
// @author       FunkyJustin
// @match        https://www.dlsite.com/maniax/work/=/product_id/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function createF95ZoneButton() {
        const gameTitle = document.querySelector('h1[id="work_name"]').innerText.trim();
        const circleNameElement = document.querySelector('span[itemprop="brand"] a');
        const circleName = circleNameElement.innerText.trim();
        let productId = window.location.href.match(/product_id\/([^\/]+)/)[1];

        // Remove the .html extension if present
        productId = productId.replace('.html', '');

        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 f95zoneCircleLink = `https://f95zone.to/sam/latest_alpha/#/cat=games/page=1/creator=${encodeURIComponent(circleName)}`;
        const f95zoneProductIdLink = `https://f95zone.to/search/?q=${encodeURIComponent(productId)}`;

        const gameButton = createButton('Search on F95Zone', f95zoneGameLink);
        const forumButton = createButton('Search on F95Zone Forums', f95zoneForumLink);
        const productIdButton = createButton('Search Product ID on F95Zone', f95zoneProductIdLink);
        const circleButton = createButton('Search Circle on F95Zone', f95zoneCircleLink);

        const titleContainer = document.querySelector('.base_title_br');
        const titleButtonWrapper = document.createElement('div');
        titleButtonWrapper.style.display = 'inline-block';
        titleButtonWrapper.style.marginLeft = '20px'; // Adjust spacing as needed

        titleButtonWrapper.appendChild(gameButton);
        titleButtonWrapper.appendChild(forumButton);
        titleButtonWrapper.appendChild(productIdButton);
        titleContainer.appendChild(titleButtonWrapper);

        const circleContainer = circleNameElement.parentNode;
        const circleButtonWrapper = document.createElement('div');
        circleButtonWrapper.style.display = 'inline-block';
        circleButtonWrapper.style.marginLeft = '10px'; // Adjust spacing as needed

        circleButtonWrapper.appendChild(circleButton);
        circleContainer.appendChild(circleButtonWrapper);

        // Click the search button on F95Zone forums page after loading
        if (window.location.href === f95zoneForumLink || window.location.href === f95zoneProductIdLink) {
            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';
        button.style.marginRight = '10px';
        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);
})();