F95Zone for RDLP torrent Search button

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

Tính đến 11-11-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 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);
})();