FarisHijazi/Rarbg-Enhancer-UserScript

Highlight/Hide Torrents with More than X-number of seeders [FEATURE REQUEST -- Code Provided]

tyhallcsu opened this issue · 3 comments

Could you implement a new feature to:

  • highlight torrents with a specific value
  • hide all torrents that don't?

Id like to enter the value in settings panel, so if i wanted to highlight torrents with 200+ seeders or some other value, those would be the ones that would be highlighted.

  1. Highlight torrents with more than X seeders
  2. Hide all torrents that do not have more than X seeders

Below is an example code I have written (it works) that highlights torrents with S value over 100 in green for better readability and faster browsing. Additionally the option to hide all non-highlighted torrents would be excellent too!

Screenshot:

CleanShot 2024-01-03 at 00 26 09@2x

Here is the userscript example that highlights torrents with more than 100 seeders.

// ==UserScript==
// @name         RARBG Torrents - Highlight Torrents 100+ Seeders
// @namespace    tampermonkey
// @version      1.0
// @description  Highlights torrents with S value over 100 in green for better readability and faster browsing.
// @author       sharmanhall
// @match        https://rarbg.to/torrents.php*
// @match        https://rarbg.to/torrents.php*
// @include      https://rarbgprx.org/torrents.php*
// @include      https://proxyrarbg.org/torrents.php*
// @include      https://rarbgunblocked.org/torrents.php*
// @include      https://rarbgaccess.org/torrents.php*
// @include      https://rarbgaccessed.org/torrents.php*
// @include      https://rarbgcore.org/torrents.php*
// @include      https://rarbgdata.org/torrents.php*
// @include      https://rarbgenter.org/torrents.php*
// @include      https://rarbgget.org/torrents.php*
// @include      https://rarbggo.org/torrents.php*
// @include      https://rarbgindex.org/torrents.php*
// @include      https://rarbgmirror.org/torrents.php*
// @include      https://rarbgmirrored.org/torrents.php*
// @include      https://rarbgp2p.org/torrents.php*
// @include      https://rarbgproxied.org/torrents.php*
// @include      https://rarbgproxies.org/torrents.php*
// @include      https://rarbgproxy.org/torrents.php*
// @include      https://rarbgto.org/torrents.php*
// @include      https://rarbgtor.org/torrents.php*
// @include      https://rarbgtorrents.org/torrents.php*
// @include      https://rarbgunblock.org/torrents.php*
// @include      https://rarbgway.org/torrents.php*
// @include      https://rarbgweb.org/torrents.php*
// @include      https://unblockedrarbg.org/torrents.php*
// @include      https://rarbg2018.org/torrents.php*
// @include      https://rarbg2019.org/torrents.php*
// @include      https://rarbg2020.org/torrents.php*
// @include      https://rarbg2021.org/torrents.php*
// @include      https://*rarbg.*
// @include      /https?:\/\/.{0,8}rarbg.*\.\/*/
// @include      /https?:\/\/.{0,8}rargb.*\.\/*/
// @include      https://*rarbg.*
// @include      https://www.rarbg.is
// @include      https://proxyrarbg.org
// @include      https://rarbg.com
// @include      https://rarbg.to
// @include      https://rarbg2018.org
// @include      https://rarbg2019.org
// @include      https://rarbg2020.org
// @include      https://rarbg2021.org
// @include      https://rarbgaccess.org
// @include      https://rarbgaccessed.org
// @include      https://rarbgcdn.org
// @include      https://rarbgcore.org
// @include      https://rarbgdata.org
// @include      https://rarbgenter.org
// @include      https://rarbgget.org
// @include      https://rarbggo.org
// @include      https://rarbgindex.org
// @include      https://rarbgmirror.com
// @include      https://rarbgmirror.org
// @include      https://rarbgmirrored.org
// @include      https://rarbgp2p.org
// @include      https://rarbgproxied.org
// @include      https://rarbgproxies.org
// @include      https://rarbgproxy.com
// @include      https://rarbgproxy.org
// @include      https://rarbgprx.org
// @include      https://rarbgto.org
// @include      https://rarbgtor.org
// @include      https://rarbgtorrents.org
// @include      https://rarbgunblock.com
// @include      https://rarbgunblock.org
// @include      https://rarbgunblocked.org
// @include      https://rarbgway.org
// @include      https://rarbgweb.org
// @include      https://unblockedrarbg.org
// @include      https://www.rarbg.is
// @icon         https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://rarbg.to&size=16
// @grant        none
// ==/UserScript==

"use strict";

$(".lista2").each(function() {
    // Extract the 'S' column value
    var sValue = $(this).find("td").eq(5).text().trim();
    var numericSValue = parseInt(sValue, 10);

    // Check if the S value is over 100 and highlight the row if true
    if (numericSValue > 100) {
        $(this).css({ background: "#c0edc8" }); // Set to green
    }
});

How to implement:

This can be done by hooking into the infScroll.on("append", ...) event in the infinite scroll userscript.

Here's an approach to integrate the highlighting logic:

  • Define the Highlighting Function in a Global Scope: Make sure the function that performs the highlighting is accessible globally or at least within the scope of both userscripts.
  • Invoke the Highlighting Function After Content Load: Modify the infinite scroll userscript to call this function each time new content is appended.

Here's how you can implement:

### Step 1: Define the Highlighting Function Globally
Modified my existing highlighting script to define the function globally:

window.highlightTorrents = function() {
    $(".lista2").each(function() {
        var sValue = $(this).find("td").eq(5).text().trim();
        var numericSValue = parseInt(sValue, 10);
        if (numericSValue > 100) {
            $(this).css({ background: "#c0edc8" }); // Set to green
        }
    });
};

// Initial highlighting
window.highlightTorrents();
image

### Step 2: Modify Infinite Scroll Script to Invoke Highlighting
In the infinite scroll userscript, modify the append event callback to invoke highlightTorrents:

infScroll.on("append", function (response, path, items) {
    // ... existing logic ...

    // Call the highlighting function after new content is appended
    if(window.highlightTorrents) {
        window.highlightTorrents();
    }
});

CleanShot 2024-01-03 at 00 55 37@2x

### HERE IS THE UPDATED EXAMPLE SCRIPT:

// ==UserScript==
// @name         RARBG Torrents - Highlight Torrents 100+ Seeders v2
// @namespace    tampermonkey
// @version      2.0
// @description  Highlights torrents with S value over 100 in green for better readability and faster browsing.
// @author       sharmanhall
// @match        https://rarbg.to/torrents.php*
// @match        https://rarbg.to/torrents.php*
// @include      https://rarbgprx.org/torrents.php*
// @include      https://proxyrarbg.org/torrents.php*
// @include      https://rarbgunblocked.org/torrents.php*
// @include      https://rarbgaccess.org/torrents.php*
// @include      https://rarbgaccessed.org/torrents.php*
// @include      https://rarbgcore.org/torrents.php*
// @include      https://rarbgdata.org/torrents.php*
// @include      https://rarbgenter.org/torrents.php*
// @include      https://rarbgget.org/torrents.php*
// @include      https://rarbggo.org/torrents.php*
// @include      https://rarbgindex.org/torrents.php*
// @include      https://rarbgmirror.org/torrents.php*
// @include      https://rarbgmirrored.org/torrents.php*
// @include      https://rarbgp2p.org/torrents.php*
// @include      https://rarbgproxied.org/torrents.php*
// @include      https://rarbgproxies.org/torrents.php*
// @include      https://rarbgproxy.org/torrents.php*
// @include      https://rarbgto.org/torrents.php*
// @include      https://rarbgtor.org/torrents.php*
// @include      https://rarbgtorrents.org/torrents.php*
// @include      https://rarbgunblock.org/torrents.php*
// @include      https://rarbgway.org/torrents.php*
// @include      https://rarbgweb.org/torrents.php*
// @include      https://unblockedrarbg.org/torrents.php*
// @include      https://rarbg2018.org/torrents.php*
// @include      https://rarbg2019.org/torrents.php*
// @include      https://rarbg2020.org/torrents.php*
// @include      https://rarbg2021.org/torrents.php*
// @include      https://*rarbg.*
// @include      /https?:\/\/.{0,8}rarbg.*\.\/*/
// @include      /https?:\/\/.{0,8}rargb.*\.\/*/
// @include      https://*rarbg.*
// @include      /https?:\/\/.{0,8}rarbg.*\.\/*/
// @include      /https?:\/\/.{0,8}rargb.*\.\/*/
// @include      /https?:\/\/.*u=MTcyLjIxLjAuMXw6Ly9yYXJiZy50by90b3JyZW50LzIyMDg3MjYwfE1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS83OS4wLjM5NDUuMTMwIFNhZmFyaS81MzcuMzZ8ODc4MDQz.*/
// @include      https://www.rarbg.is
// @include      https://proxyrarbg.org
// @include      https://rarbg.com
// @include      https://rarbg.to
// @include      https://rarbg2018.org
// @include      https://rarbg2019.org
// @include      https://rarbg2020.org
// @include      https://rarbg2021.org
// @include      https://rarbgaccess.org
// @include      https://rarbgaccessed.org
// @include      https://rarbgcdn.org
// @include      https://rarbgcore.org
// @include      https://rarbgdata.org
// @include      https://rarbgenter.org
// @include      https://rarbgget.org
// @include      https://rarbggo.org
// @include      https://rarbgindex.org
// @include      https://rarbgmirror.com
// @include      https://rarbgmirror.org
// @include      https://rarbgmirrored.org
// @include      https://rarbgp2p.org
// @include      https://rarbgproxied.org
// @include      https://rarbgproxies.org
// @include      https://rarbgproxy.com
// @include      https://rarbgproxy.org
// @include      https://rarbgprx.org
// @include      https://rarbgto.org
// @include      https://rarbgtor.org
// @include      https://rarbgtorrents.org
// @include      https://rarbgunblock.com
// @include      https://rarbgunblock.org
// @include      https://rarbgunblocked.org
// @include      https://rarbgway.org
// @include      https://rarbgweb.org
// @include      https://unblockedrarbg.org
// @include      https://www.rarbg.is
// @icon         https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://rarbg.to&size=16
// @grant        none
// ==/UserScript==

window.highlightTorrents = function() {
    $(".lista2").each(function() {
        var sValue = $(this).find("td").eq(5).text().trim();
        var numericSValue = parseInt(sValue, 10);
        if (numericSValue > 100) {
            $(this).css({ background: "#c0edc8" }); // Set to green
        }
    });
};

// Initial highlighting
window.highlightTorrents();

ok I'll try to get on that soon, if you have a the full script already working, please do share it with a pull request it'll make things easier, otherwise I'll go and explore on my own until things work

ok I'll try to get on that soon, if you have a the full script already working, please do share it with a pull request it'll make things easier, otherwise I'll go and explore on my own until things work

I appreciate you! If i write it into your script, ill share the full implementation, until then--

I wrote the script with debugging to console, and it is assuming the column it's checking is the 7th one, and it works with your infinite scroll (kinda) by checking in intervals instead of when you are appending the table.

// ==UserScript==
// @name         RARBG Torrents - Periodic Highlight Based on S Value
// @namespace    tampermonkey
// @version      1.0
// @author       sharmanhall
// @description  Periodically highlights torrents with S value over 100 in green.
// @match        https://rarbg.to/torrents.php*
// @match        https://rarbg.to/torrents.php*
// @match        https://rarbg.to/torrents.php*
// @include      https://rarbgprx.org/torrents.php*
// @include      https://proxyrarbg.org/torrents.php*
// @include      https://rarbgunblocked.org/torrents.php*
// @include      https://rarbgaccess.org/torrents.php*
// @include      https://rarbgaccessed.org/torrents.php*
// @include      https://rarbgcore.org/torrents.php*
// @include      https://rarbgdata.org/torrents.php*
// @include      https://rarbgenter.org/torrents.php*
// @include      https://rarbgget.org/torrents.php*
// @include      https://rarbggo.org/torrents.php*
// @include      https://rarbgindex.org/torrents.php*
// @include      https://rarbgmirror.org/torrents.php*
// @include      https://rarbgmirrored.org/torrents.php*
// @include      https://rarbgp2p.org/torrents.php*
// @include      https://rarbgproxied.org/torrents.php*
// @include      https://rarbgproxies.org/torrents.php*
// @include      https://rarbgproxy.org/torrents.php*
// @include      https://rarbgto.org/torrents.php*
// @include      https://rarbgtor.org/torrents.php*
// @include      https://rarbgtorrents.org/torrents.php*
// @include      https://rarbgunblock.org/torrents.php*
// @include      https://rarbgway.org/torrents.php*
// @include      https://rarbgweb.org/torrents.php*
// @include      https://unblockedrarbg.org/torrents.php*
// @include      https://rarbg2018.org/torrents.php*
// @include      https://rarbg2019.org/torrents.php*
// @include      https://rarbg2020.org/torrents.php*
// @include      https://rarbg2021.org/torrents.php*
// @include      https://*rarbg.*
// @include      /https?:\/\/.{0,8}rarbg.*\.\/*/
// @include      /https?:\/\/.{0,8}rargb.*\.\/*/
// @include      https://*rarbg.*
// @include      /https?:\/\/.{0,8}rarbg.*\.\/*/
// @include      /https?:\/\/.{0,8}rargb.*\.\/*/
// @include      /https?:\/\/.*u=MTcyLjIxLjAuMXw6Ly9yYXJiZy50by90b3JyZW50LzIyMDg3MjYwfE1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0LzUzNy4zNiAoS0hUTUwsIGxpa2UgR2Vja28pIENocm9tZS83OS4wLjM5NDUuMTMwIFNhZmFyaS81MzcuMzZ8ODc4MDQz.*/
// @include      https://www.rarbg.is
// @include      https://proxyrarbg.org
// @include      https://rarbg.com
// @include      https://rarbg.to
// @include      https://rarbg2018.org
// @include      https://rarbg2019.org
// @include      https://rarbg2020.org
// @include      https://rarbg2021.org
// @include      https://rarbgaccess.org
// @include      https://rarbgaccessed.org
// @include      https://rarbgcdn.org
// @include      https://rarbgcore.org
// @include      https://rarbgdata.org
// @include      https://rarbgenter.org
// @include      https://rarbgget.org
// @include      https://rarbggo.org
// @include      https://rarbgindex.org
// @include      https://rarbgmirror.com
// @include      https://rarbgmirror.org
// @include      https://rarbgmirrored.org
// @include      https://rarbgp2p.org
// @include      https://rarbgproxied.org
// @include      https://rarbgproxies.org
// @include      https://rarbgproxy.com
// @include      https://rarbgproxy.org
// @include      https://rarbgprx.org
// @include      https://rarbgto.org
// @include      https://rarbgtor.org
// @include      https://rarbgtorrents.org
// @include      https://rarbgunblock.com
// @include      https://rarbgunblock.org
// @include      https://rarbgunblocked.org
// @include      https://rarbgway.org
// @include      https://rarbgweb.org
// @include      https://unblockedrarbg.org
// @include      https://www.rarbg.is
// @icon         https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://rarbg.to&size=16
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function highlightTorrents() {
        console.log("Running highlightTorrents");

        var countHighlighted = 0;

        // Iterate over each row in the torrent list
        $(".lista2").each(function(index) {
            // Find the 'S' column (assuming it's the 7th column)
            var sValueText = $(this).find("td").eq(6).text().trim();
            var sValue = parseInt(sValueText, 10); // Convert the text to a number

            console.log("Row " + index + ": S Value = " + sValue);

            // Check if the S value is greater than 100
            if (!isNaN(sValue) && sValue > 200) {
                $(this).css({ background: "#c0edc8" }); // Apply green background
                countHighlighted++;
            }
        });

        console.log(countHighlighted + " rows highlighted");
    }

    // Initial highlighting
    highlightTorrents();

    // Re-apply highlighting every second
    setInterval(highlightTorrents, 2000);
})();