F95Zone for RDLP torrent Search button

Adds a button to search on RDLP when you are on the game thread.

Stan na 11-11-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        F95Zone for RDLP torrent Search button
// @namespace   Violentmonkey Scripts
// @match       https://f95zone.to/threads/*
// @grant       none
// @version     1.0
// @author      UglyOldLazyBastard
// @license WTFPL http://www.wtfpl.net/faq/
// @description Adds a button to search on RDLP when you are on the game thread.
// ==/UserScript==

(function() {
    'use strict';

      function removeSpecials(str) {
        var lower = str.toLowerCase();
        var upper = str.toUpperCase();

        var res = "";
        for(var i=0; i<lower.length; ++i) {
            if(lower[i] != upper[i] || lower[i].trim() === '')
                res += str[i];
        }
        return res;
      }



    // Function to create and add the button
    function addRDLPSearchButton() {
        // Get the text from h1.p-title-value
        const titleElement = document.querySelector('h1.p-title-value');
        if (!titleElement) return;

        let searchText = Array.from(titleElement.childNodes)
            .filter(node => node.nodeType === Node.TEXT_NODE)
            .map(node => node.textContent.trim())
            .join(' ')
            .trim();
        searchText = searchText.split("[")[0].trim();
        searchText = removeSpecials(searchText);
        console.log(searchText);

        // Create the new button
        const newButton = document.createElement('a');
        newButton.href = `https://dl.rpdl.net/torrents?search=${encodeURIComponent(searchText)}`;
        newButton.className = 'button--link button';
        newButton.innerHTML = '<span class="button-text">Search on RDLP</span>';

        // Find the .buttonGroup element
        const buttonGroup = document.querySelector('.buttonGroup');
        if (buttonGroup) {
            // Add the new button to the button group
            buttonGroup.appendChild(newButton);
        }
    }



    // Run the function when the page is fully loaded
    window.addEventListener('load', addRDLPSearchButton);
})();