 
        Greasy Fork is available in English.
Just like RARBG Advanced Filters with the benefit of permanently removing pornography for those who would rather not see such content. Forked off of v1.42.
当前为 
// ==UserScript==
// @name         RARBG Advanced Filters [No Porn Edition]
// @namespace    http://tampermonkey.net/
// @version      1.61
// @description  Just like RARBG Advanced Filters with the benefit of permanently removing pornography for those who would rather not see such content. Forked off of v1.42.
// @author       Kxmode
// @contributor  darkred, phpcitizen
// @license      MIT
// @include      /(https?:)?\/\/(www\.)?(proxy|unblocked)?rarbg((2018|2019|2020|2021)?|access(ed)?|cdn|core|data|enter|get|go|index|mirror(ed)?|p2p|prox(ied|ies|y)|prx|to(r|rrents)?|unblock(ed)?|way|web)\.(to|com|org|is)\/((index\d{2}|torrents)\.php.*|torrent|catalog\/.*|s\/.*|tv\/.*|top10)/
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
// @run-at       document-idle
// ==/UserScript==
const $ = (window).$;
$(function() {
    // Define general variables
    var nonStandardUrlParams = (GetParameterByName("category%5B%5D") !== null || GetParameterByName("category[]") !== null) ? true : false,
        arrayCurrentUrlParams = -1,
        showAdvancedOptions = false,
        showIcon,
        showTorrentThumbnail, // TODO: child of showIcon (=true)
        showMoviesTVFilters,
        genreFilter = "",
        currentUrlNormal,
        currentUrlAbnormal,
        i;
    // Define Category specific filters
    var minRating,
        searchGenre,
        gameGroup,
        musicGenre,
        showKORSUB,
        show720p;
    // Define array of known RARBG categories
    var arrayMovies = ["movies", 14, 17, 42, 44, 45, 46, 47, 48, 50, 51, 52, 54].map(String),
        arrayTVShows = [18, 41, 49].map(String),
        arrayGames = [27, 28, 29, 30, 31, 32, 40].map(String),
        arrayMusic = [23, 24, 25, 26].map(String),
        arraySoftware = [33, 34, 43].map(String),
        arrayNonPorn = [14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52].map(String);
    // Define conditional checks
    var isCategoryMovies,
        isCategoryTVShows,
        isCategoryGames,
        isCategoryMusic,
        isCategorySoftware,
        isCategoryNonPorn;
    // Define booleans
    var categoryMoviesArray,
        categoryTVShowsArray,
        categoryGamesArray,
        categoryMusicArray,
        categorySoftwareArray,
        categoryNonPornArray;
    // This logic normalizes RARBG's inconsistent URL parameter types (e.g. category=movies, category%5B%5D=48, category=1;18;41;49;, and category[]=42)
    if (nonStandardUrlParams)
    {
        currentUrlNormal = new RegExp("[\?&]category%5B%5D=([^]*)").exec(window.location.href); // Grab all URL parameters %5B%5D
        currentUrlAbnormal = new RegExp("[\?&]category\[[^\[\]]*\]=([^]*)").exec(window.location.href); // Grab all URL parameters []
        if (currentUrlNormal === null && currentUrlAbnormal === null) // If neither unique parameter exists, then stop this logic, and return nothing
        {
            return null;
        }
        else // Otherwise...
        {
            if (currentUrlAbnormal !== null) // If URL parameters is [] (abnormal)
            {
                arrayCurrentUrlParams = String(currentUrlAbnormal).match(/(=)\w+/g).map(String); // Create an array of values separated by the equal sign
            }
            else // Otherwise conclude URL parameters are normal (%5B%5D)
            {
                arrayCurrentUrlParams = String(currentUrlNormal).match(/(=)\w+/g).map(String); // Create an array of values separated by the equal sign
            }
            for (i = 0; i < arrayCurrentUrlParams.length; i++) // Iterate through array look for equal signs
            {
                arrayCurrentUrlParams[i] = arrayCurrentUrlParams[i].replace("=", ""); // Remove the equal sign from the array
            }
        }
    }
    else if (GetParameterByName("category") !== null || arrayCurrentUrlParams.length > -1) // Otherwise this is a standard URL parameter
    {
        arrayCurrentUrlParams = GetParameterByName("category").split(";").map(String); // Create an array of values separated by the semicolon
    }
    // Compares current url parameters with known RARBG categories. If the value is greater than -1 we have at least one match.
    if (GetParameterByName("category") !== null || arrayCurrentUrlParams.length > -1)
    {
        // Navigate through each array to find and set the match to true. For now there can only be one match.
        for (i = 0; i < arrayCurrentUrlParams.length; i++)
        {
            isCategoryMovies = arrayMovies.indexOf(arrayCurrentUrlParams[i]);
            categoryMoviesArray = (isCategoryMovies !== -1) ? true : false;
        }
        for (i = 0; i < arrayCurrentUrlParams.length; i++)
        {
            isCategoryTVShows = arrayTVShows.indexOf(arrayCurrentUrlParams[i]);
            categoryTVShowsArray = (isCategoryTVShows !== -1) ? true : false;
        }
        for (i = 0; i < arrayCurrentUrlParams.length; i++)
        {
            isCategoryGames = arrayGames.indexOf(arrayCurrentUrlParams[i]);
            categoryGamesArray = (isCategoryGames !== -1) ? true : false;
        }
        for (i = 0; i < arrayCurrentUrlParams.length; i++)
        {
            isCategoryMusic = arrayMusic.indexOf(arrayCurrentUrlParams[i]);
            categoryMusicArray = (isCategoryMusic !== -1) ? true : false;
        }
        for (i = 0; i < arrayCurrentUrlParams.length; i++)
        {
            isCategorySoftware = arraySoftware.indexOf(arrayCurrentUrlParams[i]);
            categorySoftwareArray = (isCategorySoftware !== -1) ? true : false;
        }
        for (i = 0; i < arrayCurrentUrlParams.length; i++)
        {
            isCategoryNonPorn = arrayNonPorn.indexOf(arrayCurrentUrlParams[i]);
            categoryNonPornArray = (isCategoryNonPorn !== -1) ? true : false;
        }
    }
    // Method to grab the Parameter name and value (Note: single use only. See line 60 for multiple URL parameters and if needed move to function.)
    function GetParameterByName(name, url) {
        // credit: https://stackoverflow.com/a/901144 (Modified by Kxmode)
        // Used under StackOverflow's standard CC BY-SA 3.0 license
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$|((%\d\D)*\D\d*))'),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    // Method to activate and deactive filters inside the Advanced Filter's HTML box
    function ToggleFilter(target, data, bool, optional)
    {
        optional = (optional !== undefined) ? true : false;
        var targetID = target.replace("#","");
        if (bool)
        {
            if (!optional)
            {
                $(target).find("i").removeClass("fa-eye-slash").addClass("fa-eye");
                $(target).removeClass("disabled");
            }
            $(target).attr(data, "true");
            window.localStorage.setItem(targetID, "true");
        }
        else
        {
            if (!optional)
            {
                $(target).find("i").removeClass("fa-eye").addClass("fa-eye-slash");
                $(target).addClass("disabled");
            }
            $(target).attr(data, "false");
            window.localStorage.setItem(targetID, "false");
        }
    }
    // Method to show and hide the Advanced Filter's HTML box
    function ToggleAdvancedFilters(bool, isClicked)
    {
        isClicked = (isClicked !== undefined) ? true : false;
        var parentTarget = $(".new-search form");
        var target = $(".advanced-search");
        if (GetParameterByName("category") !== null && isClicked === false)
        {
            if (bool) {
                window.localStorage.setItem("shadvbutton", "true");
                parentTarget.removeAttr("style");
                parentTarget.removeClass("disabled");
                target.show();
                $("#shadvbutton").text("«");
            } else {
                parentTarget.attr("style", "width: 100%; border-right: 1px solid #9faabc;");
                target.hide();
                $("#shadvbutton").text("»");
            }
        }
        else if (GetParameterByName("category") === null && isClicked === false)
        {
            $("#shadvbutton").attr("data-shadvbutton", "false");
            window.localStorage.setItem("shadvbutton", "false");
            parentTarget.attr("style", "width: 100%; border-right: 1px solid #9faabc;");
            target.hide();
            $("#shadvbutton").text("»");
        }
        else
        {
            if (bool) {
                if (typeof showhideadvsearch !== "undefined") { showhideadvsearch('show'); }
                parentTarget.removeAttr("style");
                parentTarget.removeClass("disabled");
                target.show();
                $("#shadvbutton").text("«");
            } else {
                parentTarget.attr("style", "width: 100%; border-right: 1px solid #9faabc;");
                target.hide();
                $("#shadvbutton").text("»");
            }
        }
    }
    $("#searchTorrent").parent().addClass("new-search");
    // Removes extra space between Recommended torrents and search bar
    $("#searchTorrent").parent().parent().find("div:nth-of-type(2)").remove();
    for(i = 1; i <= 4; i++)
    {
        $("#searchTorrent").parent().parent().find("br:nth-of-type(1)").remove();
    }
    // Fixes a bug in this script affecting the formatting of IMDB searches (?imdb=tt0448115) in darkred's "RARBG - various tweaks";
    if ($(".new-search").next().attr("class") === undefined)
    {
        $(".new-search").next().find("table tr td:last-child").addClass("advanced-search-formatting-fix");
        $("<br>").insertBefore(".advanced-search-formatting-fix b:nth-of-type(-n+5)");
    }
    // Attaches FontAwesome script to display active and inactive "eye" icons. fontawesome.io for more info.
    $("head").append( '<script src="https://kit.fontawesome.com/515872dda2.js" crossorigin="anonymous"></script>');
    // Attaches CSS for the custom Advanced Filters HTML box.
    $("head").append( '<style>\n' +
                     '.content-rounded .new-search,\n' +
                     '.content-rounded div.new-search div    { margin-left: auto; }\n' +
                     '.new-search                            { width: 1200px; display: flex; display: -webkit-flex; display: -moz-flex; margin: 30px auto; }\n' +
                     '.new-search div                        { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }\n' +
                     '.new-search div                        { border-radius: 0; -moz-border-radius: 0; -webkit-border-radius: 0; }\n' +
                     '.new-search form                       { width: 70%; border-radius: 0; -moz-border-radius: 0; -webkit-border-radius: 0; }\n' +
                     '.new-search form                       { border: 0; border-top: 1px solid #9faabc; border-bottom: 1px solid #9faabc; border-left: 1px solid #9faabc; }\n' +
                     '.new-search .divadvscat                { width: 157px; display: inline-block; height: auto; padding: 7px; float: none; }\n' +
                     '.new-search .divadvclearcats           { padding: 10px; }\n' +
                     '.new-search .advanced-search           { width: 31%; background: #e7f3fb; font-size: 110%; padding: 5px; border: 1px solid #9faabc; float: left; }\n' +
                     '.new-search .advanced-search           { border: 0; border-top: 1px solid #9faabc; border-bottom: 1px solid #9faabc; border-right: 1px solid #9faabc; }\n' +
                     '.new-search .advanced-search h4        { padding: 0; margin: 0 0 10px 0; text-align: center; }\n' +
                     '.advanced-search .section-wrapper      { border: 1px dotted #9faabc; padding: 10px; }\n' +
                     '.advanced-search .section-wrapper:first-child { border-bottom: 0; }\n' +
                     '.advanced-search .no-border            { border: 0; }\n' +
                     '.advanced-search .divadvscat           { width: auto; border: 1px solid transparent; cursor: pointer; }\n' +
                     '.advanced-search .divadvscat i         { padding-right: 2px; }\n' +
                     '.advanced-search .disabled             { border: 1px solid #DDD; background-color: #f5f5f5; color: #999; }\n' +
                     '.advanced-search .centered             { text-align: center; }\n' +
                     '.section-wrapper .imdb-rating-search   { width: 155px; }\n' +
                     '.section-wrapper .genre-search         { width: auto; }\n' +
                     '.section-wrapper .gaming-group-search  { width: auto; }\n' +
                     '.section-wrapper .imdb-rating-search input         { width: 30%; }\n' +
                     '.section-wrapper .gaming-group-search input        { width: 50%; }\n' +
                     '.section-wrapper input                 { border: 0; margin-left: 10px; border: 1px solid #9faabc; text-align: center; }\n' +
                     '.clearfix:before, .clearfix:after      { display: table; content: ""; line-height: 0;}\n' +
                     '.section-wrapper input.text-left       { text-align: left; }\n' +
                     'td.header6:hover                       { background: #3860bb; cursor: default;; }\n' +
                     'td.header6 span                        { text-decoration: underline; cursor: pointer; }\n' +
                     'td.header6 span:hover                  { text-decoration: none; }\n' +
                     '.resize                                { width: 65%; }\n' +
                     '</style>');
    // Creates the HTML for category specific filters
    if (GetParameterByName("category") === null || categorySoftwareArray)
    {
        genreFilter = '<div class="section-wrapper no-border" style="border-top: 1px dotted #9faabc;">\n';
    }
    else
    {
        genreFilter = '<div class="section-wrapper">\n';
    }
    // TODO: Handle for: if (GetParameterByName("category") !== null || arrayCurrentUrlParams.length > -1 || nonStandardUrlParams) ----------
    if (GetParameterByName("category") !== null || nonStandardUrlParams)
    {
        if (categoryMoviesArray || categoryTVShowsArray)
        {
            genreFilter += '<div id="jQIMDB" class="divadvscat imdb-rating-search centered">Min Rating <input name="minprice" type="text" /></div>\n' +
                           '<div id="jQKORSUB" class="divadvscat" title="Hides low-quality KORSUB torrents"><i class="fa fa-eye fa-1x"></i> KORSUB</div>\n' +
                           '<div id="jQ720p" class="divadvscat" title="Hides 720p torrents"><i class="fa fa-eye fa-1x"></i> 720p</div>\n' +
                           '<div id="jQgenre" class="divadvscat genre-search">Genre <input name="mediagenre" type="text" class="text-left" /></div>\n';
        }
        else if (categoryGamesArray)
        {
            genreFilter += '<div id="jQGamingGroup" class="divadvscat gaming-group-search centered">Torrent Group <input name="gamegroup" class="text-left" type="text" /></div>\n';
        }
        else if (categoryMusicArray)
        {
            genreFilter += '<div id="jQMusicGenre" class="divadvscat music-group-genre centered">Genre <input name="musicgenre" class="text-left" type="text" /></div>\n';
        }
        else if (categorySoftwareArray)
        {
            // genreFilter += '<div id="jQcategoryFilter" class="divadvscat centered">Software Filters Coming Soon</div>\n';    // Not enough to warrant this for now
        }
        else if (categoryNonPornArray)
        {
            genreFilter += '<div id="jQcategoryFilter" class="divadvscat centered">Non Porn Filters Coming Soon</div>\n';
        }
    }
    else
    {
        // genreFilter += '<div id="jQcategoryFilter" class="divadvscat centered">All Filters Coming Soon</div>\n';            // Not enough to warrant this for now
    }
    genreFilter += '</div>\n';
    // Creates the Advanced Filter HTML box
    var AdvancedFiltersHTML = '<div class="advanced-search">\n' +
                                        '<div class="section-wrapper">\n' +
                                                '<div id="jQIcon" class="divadvscat"><i class="fa fa-eye fa-1x"></i> Category Icons</div>\n' +
                                                '<div id="jQTorrentThumbnail" class="divadvscat"><i class="fa fa-eye fa-1x"></i> Torrent Images</div>\n' + // Eventually make this a child of Show Thumbnails
                                        '</div>\n' +
                                        genreFilter +
                                        '<div class="section-wrapper no-border">\n' +
                                                '<span class="jQUpdateFilters btn btn-primary btn-mini">Update Page with Filters</span>\n' +
                                                '<span class="jQResetFilters btn btn-mini">Reset Filters</span>\n' +
                                        '</div>\n' +
                                        '<div class="clearfix"></div>\n' +
                                '</div>';
    // Attaches Advanced Filters HTML box to RARBG
    $("#searchTorrent").parent().append(AdvancedFiltersHTML);
    // TODO: Likely going to need to move the ToggleFilter and ToggleAdvancedFilters method calls into this gated logic
    if (nonStandardUrlParams)
    {
        ToggleFilter("#shadvbutton", "data-shadvbutton", showAdvancedOptions, true);
        ToggleAdvancedFilters(true, true);
    }
    else
    {
        showAdvancedOptions = ((window.localStorage.getItem("shadvbutton") == "true") ? true : false);
        ToggleFilter("#shadvbutton", "data-shadvbutton", showAdvancedOptions, true);
        ToggleAdvancedFilters(showAdvancedOptions);
    }
    // Logic for HTML box icons
    showIcon = ((window.localStorage.getItem("jQIcon") == "false") ? false : true);
    ToggleFilter("#jQIcon", "data-icon", showIcon);
    showTorrentThumbnail = ((window.localStorage.getItem("jQTorrentThumbnail") == "false") ? false : true);
    ToggleFilter("#jQTorrentThumbnail", "data-torrent-thumbs", showTorrentThumbnail);
    showKORSUB = ((window.localStorage.getItem("jQKORSUB") == "false") ? false : true);
    ToggleFilter("#jQKORSUB", "data-korsub", showKORSUB);
    show720p = ((window.localStorage.getItem("jQ720p") == "false") ? false : true);
    ToggleFilter("#jQ720p", "data-720p", show720p);
    $("#shadvbutton").on("click", function() {
        showAdvancedOptions = ($(this).attr("data-shadvbutton") == "false") ? true : false;
        ToggleFilter("#shadvbutton", "data-shadvbutton", showAdvancedOptions, true);
        ToggleAdvancedFilters(showAdvancedOptions, true);
    });
    $("#jQIcon").on("click", function() {
        showIcon = ($(this).attr("data-icon") == "false") ? true : false;
        ToggleFilter("#jQIcon", "data-icon", showIcon);
    });
    $("#jQTorrentThumbnail").on("click", function() {
        showTorrentThumbnail = ($(this).attr("data-torrent-thumbs") == "false") ? true : false;
        ToggleFilter("#jQTorrentThumbnail", "data-torrent-thumbs", showTorrentThumbnail);
    });
    $("#jQKORSUB").on("click", function() {
        showKORSUB = ($(this).attr("data-korsub") == "false") ? true : false;
        ToggleFilter("#jQKORSUB", "data-korsub", showKORSUB);
    });
    $("#jQ720p").on("click", function() {
        show720p = ($(this).attr("data-720p") == "false") ? true : false;
        ToggleFilter("#jQ720p", "data-720p", show720p);
    });
    // Movies and TV Shows only
    if (categoryMoviesArray || categoryTVShowsArray)
    {
        if (window.localStorage.getItem("minimum-rating") > 0)
        {
            var mr = window.localStorage.getItem("minimum-rating");
            $("#jQIMDB").find("input").attr("value", mr);
            minRating = mr;
        }
        else
        {
            $("#jQIMDB").find("input").attr("value", 0);
        }
        if (window.localStorage.getItem("media-genre") !== null)
        {
            var gen = window.localStorage.getItem("media-genre");
            $("#jQgenre").find("input").attr("value", gen);
            searchGenre = gen.toLowerCase();
        }
    }
    // Games only
    if (categoryGamesArray)
    {
        if(window.localStorage.getItem("game-group") !== undefined)
        {
            var gg = window.localStorage.getItem("game-group");
            $("#jQGamingGroup").find("input").attr("value", gg);
            gameGroup = gg;
        }
        else
        {
            $("#jQGamingGroup").find("input").removeAttr("value");
        }
    }
    // Music only
    if (categoryMusicArray)
    {
        if(window.localStorage.getItem("music-genre") !== undefined)
        {
            var mg = window.localStorage.getItem("music-genre");
            $("#jQMusicGenre").find("input").attr("value", mg);
            musicGenre = mg;
        }
        else
        {
            $("#jQMusicGenre").find("input").removeAttr("value");
        }
    }
    // Input click event
    $("#jQIMDB input, #jQGamingGroup input, #jQMusicGenre input, #jQgenre input").on("keydown", function() {
        if (event.which == 13 || event.keyCode == 13) {
            $(".jQUpdateFilters").click();
        }
    });
    // Events for the "Update Filters" button
    $(".jQUpdateFilters").on("click", function () {
        if (categoryMoviesArray || categoryTVShowsArray)
        {
            var minRating = $("#jQIMDB").parent().find("input").val();
            window.localStorage.setItem("minimum-rating", minRating);
            var genre = $("#jQgenre").find("input").val();
            window.localStorage.setItem("media-genre", genre);
        }
        if (categoryGamesArray)
        {
            var gameGroup = $("#jQGamingGroup").parent().find("input").val();
            window.localStorage.setItem("game-group", gameGroup);
        }
        if (categoryMusicArray)
        {
            var musicGenre = $("#jQMusicGenre").parent().find("input").val();
            window.localStorage.setItem("music-genre", musicGenre);
        }
        location.reload();
    });
    // Events for the "Reset Filters" button
    $(".jQResetFilters").on("click", function() {
        window.localStorage.removeItem("jQIcon");
        window.localStorage.removeItem("jQTorrentThumbnail");
        window.localStorage.removeItem("jQKORSUB");
        window.localStorage.removeItem("jQ720p");
        window.localStorage.removeItem("media-genre");
        window.localStorage.removeItem("minimum-rating");
        window.localStorage.removeItem("game-group");
        window.localStorage.removeItem("music-genre");
        location.reload();
    });
    // Removes Movie filters after clicking the "View all" link
    $(".tdlinkfull2").on("click", function() {
        if ($(this).text() === "View all")
        {
            window.localStorage.removeItem("jQKORSUB");
            window.localStorage.removeItem("jQ720p");
            window.localStorage.removeItem("minimum-rating");
            window.localStorage.removeItem("game-group");
            window.localStorage.removeItem("music-genre");
            window.localStorage.removeItem("media-genre");
        }
    });
    // CATEGORY SPECIFIC =================================================================================================
    // Hides torrents with seeders equal to or lower than a number [TODO: make this a form input filter]
    // use inArray method from work (Configurator height normalizer)
    /*
    if (parseInt(title.indexOf("720p")) > 0)
    {
        $(this).parents(".lista2").remove();
    }
    */
    // Logic to hide porn
    $.each($(".tdlinkfull2"), function() {
        var targetText = $(this).text().toLowerCase();
        if (targetText == "xxx")
        {
            $(this).parent().parent().remove();
        }
    });
    $.each($(".divadvscat a"), function() {
        var targetText = $(this).text().toLowerCase();
        if(targetText == "xxx (18+)")
        {
            $(this).parent().remove();
        }
    });
    // Loops through all torrents looking at each span tag
    $.each($(".lista span"), function(index, value) {
        var genre = $(this).text().toLowerCase();
        if (genre !== undefined)
        {
            // Creates the logic for category specific filters
            if (GetParameterByName("category") !== null || nonStandardUrlParams)
            {
                if (categoryMoviesArray || categoryTVShowsArray)
                {
                    // Genres
                    if (genre.search(searchGenre) == -1)
                    {
                        $(this).parents(".lista2").remove();
                    }
                }
            }
        }
    });
    // Loops through all torrents looking at each anchor tag
    $.each($(".lista a"), function(index, value) {
        var title = $(this).attr("title");
        var icon = $(this).find("img").attr("src");
        if (title !== undefined)
        {
            // Logic to hide KORSUB torrents
            if (!showKORSUB)
            {
                if (parseInt(title.indexOf("KORSUB")) > 0)
                {
                    $(this).parents(".lista2").remove();
                }
            }
            // Logic to hide 720p torrents
            if (!show720p)
            {
                if (parseInt(title.indexOf("720p")) > 0)
                {
                    $(this).parents(".lista2").remove();
                }
            }
            // Creates the logic for category specific filters
            if (GetParameterByName("category") !== null || nonStandardUrlParams)
            {
                if (categoryMoviesArray || categoryTVShowsArray)
                {
                    // IMDB Ratings
                    $.each($(".lista:nth-child(2)"), function(index, value) {
                        if ($(this).children("span").length) {
                            var ratings = $(this).children("span").text();
                            var imdb = ratings.indexOf("IMDB: ") + 6;
                            var scopemr = $("#jQIMDB").parent().find("input").val();
                            if (scopemr > 0)
                            {
                                if (ratings !== undefined && imdb !== -1)
                                {
                                    minRating = parseFloat(minRating);
                                    var rateValue = parseFloat(ratings.substring(imdb,ratings.length-3));
                                    if (!isNaN(rateValue))
                                    {
                                        if (showMoviesTVFilters) { $(this).children("span").attr("style", "display: block;"); }
                                        if (rateValue <= minRating)
                                        {
                                            $(this).parents(".lista2").remove();
                                        }
                                    }
                                    else
                                    {
                                        $(this).parents(".lista2").remove();
                                    }
                                }
                            }
                        }
                    });
                }
                // Game Torrent Group
                else if (categoryGamesArray)
                {
                    $.each($(".lista2t a"), function(index, value) {
                        if ($(this).attr("title") !== undefined)
                        {
                            var torrentTitle = $(this).attr("title");
                            var searchValue = torrentTitle.toLowerCase().indexOf(gameGroup);
                            var compareValue = torrentTitle.substring(searchValue,torrentTitle.length);
                            if (searchValue === -1 && gameGroup !== null)
                            {
                                $(this).parents(".lista2").remove();
                            }
                        }
                    });
                }
                else if (categoryMusicArray)
                {
                    $.each($(".lista2t .lista span:last-child"), function(index, value) {
                        var genreTitle = $(this).text();
                        if (genreTitle !== undefined)
                        {
                            var searchValue = genreTitle.toLowerCase().indexOf(musicGenre);
                            var compareValue = genreTitle.substring(searchValue,genreTitle.length);
                            if (searchValue === -1 && musicGenre !== null)
                            {
                                $(this).parents(".lista2").remove();
                            }
                        }
                    });
                }
                // Coming soon
                else if (categorySoftwareArray) { }
                else if (categoryNonPornArray) { }
            }
        }
        // Logic to hide porn
        if (title !== undefined)
        {
            title = title.indexOf("XXX");
            if (title >= 0)
            {
                $(this).parents(".lista2").remove();
            }
        }
        if (icon !== undefined)
        {
            icon = icon.indexOf("cat_new4.gif");
            if (icon >= 0)
            {
                $(this).parents(".lista2").remove();
            }
        }
    });
    // NON-CATEGORY SPECIFIC =================================================================================================
    // Logic to hide icons
    if (!showIcon)
    {
        $(".lista2t tr td:nth-of-type(1)").attr("style","display:none;");
    }
    else
    {
        // TODO: Make child of showIcon (=true)
        // Logic to show torrent thumbnails
        if (showTorrentThumbnail)
        {
            var LSsetting = "RARBG-Advanced-Filters-Large-Thumbnails";
            window.isLargeThumb = ( window.localStorage.getItem(LSsetting) == "true" ) ? true : false;
            if (window.isLargeThumb) {
                $(".lista2t").find("tr:first-child td:first-child").html("Thumbnail (<span class='jQlargeThumbs'><i class='fas fa-compress-arrows-alt'></i></span>)");
            } else {
                $(".lista2t").find("tr:first-child td:first-child").html("Thumbnail (<span class='jQlargeThumbs'><i class='fas fa-expand-arrows-alt'></i></span>)");
            }
            $.each($(".lista2t .lista2"), function() {
                var anchor = $(this);
                $.each(anchor.find(".lista"), function() {
                    var image = $(this).find("a");
                    var target = anchor.find(":nth-child(1) a");
                    if (image.attr("onmouseover") !== undefined)
                    {
                        var href = image.attr("href");
                        var sourceThumb = image.attr("onmouseover");
                        var val1 = sourceThumb.match(/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/g).map(String)[0];
                        val1 = sourceThumb.lastIndexOf(val1);
                        var val2 = sourceThumb.indexOf("\' border=0>')")-1;
                        var imageID = sourceThumb.substring(val1,val2);
                        if (window.isLargeThumb)
                        {
                            if (imageID.includes("static/over"))
                            {
                                var pvid = imageID.substring(22,23);
                                imageID = imageID.replace("static/over","posters2/" + pvid);
                            }
                            if (imageID.includes("over_opt"))
                            {
                                imageID = imageID.replace("over_opt","poster_opt");
                            }
                            if (imageID.includes("_small"))
                            {
                                imageID = imageID.replace("_small","_banner_optimized");
                            }
                        }
                        var thumbnailImage = "<img class='thumbnail' src=\'//" + imageID + "' />";
                        if (window.isLargeThumb)
                        {
                            if (imageID.includes("posters2/") || imageID.includes("poster_opt") || imageID.includes("_banner_optimized"))
                            {
                                $(".thumbnail").addClass("resize");
                            }
                        }
                        image.removeAttr("onmouseover").removeAttr("onmouseout");
                        target.find("img").replaceWith(thumbnailImage);
                        target.attr("href", href);
                        anchor.find("td:nth-child(1)").attr( "align", "center" );
                    }
                });
            });
            $(document).on("click", ".jQlargeThumbs", function() {
                if(window.isLargeThumb) {
                    window.localStorage.setItem(LSsetting, "false");
                } else {
                    window.localStorage.setItem(LSsetting, "true");
                }
                window.location.href = window.location.href;
            });
        }
    }
    // May need to update to DOM structure changes
    $("body > div:last-of-type").prev().prev().prev().remove();
    $("body > div:last-of-type").prev().remove();
    // Is Grid active?
    var showGrid = ((window.localStorage.getItem("advanced-search-grid-view") == "true") ? true : false);
    // Creates the Grid button toggle
    var gridIcon = showGrid ? "<i class=\"fas fa-list\"></i>" : "<i class=\"fas fa-th\"></i>";
    var tooltip = showGrid ? "Show list view" : "Show grid view";
    $("#searchTorrent table tbody tr").prepend("<td><span class=\"btn btn-primary jQGridButton\" title=\"" + tooltip + "\">" + gridIcon + "</a></td>");
    // Grid button toggle logic
    $(document).on("click", ".jQGridButton", function() {
        if (showGrid) {
            window.localStorage.setItem("advanced-search-grid-view", "false");
        } else {
            window.localStorage.setItem("advanced-search-grid-view", "true");
        }
        location.reload();
    });
    if (showGrid) {
        var isTorrentMagnetLinksScriptActive = false;
        // Determines if the torrent and magnet links script is installed
        $.each($(".lista2t tbody tr:first-child td"), function(index) {
            var content = $(this).html();
            switch (content) {
                case "DL ML":
                    isTorrentMagnetLinksScriptActive = true;
                    break;
            }
        });
        // Creates the CSS for the grid
        $("<div id=\"TorrentGrid\"/>").insertBefore(".lista2t").prepend('<style>\n' +
                                                                        '#TorrentGrid .grid-lista2                          { display: grid; grid-template-rows: 220px 60px 45px 27px; }\n' +
                                                                        '#TorrentGrid .grid-lista2                          { width: 20%; background-color: #e7f3fa; border: 10px solid #fff; margin: 0 !important; padding: 20px; text-align: center; float: left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .lista                   { margin: 0; }\n' +
                                                                        '#TorrentGrid .alt-layout                           { display:block; min-height: 30px; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .alt-darker              { background: #222; font-weight: bold; color: #fff; padding: 5px; margin: 5px 0; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .alt-deco                { border-bottom: 1px solid #CCC; padding-bottom: 5px; margin-bottom: 5px; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .lista:first-child img   { width: 100%; height: 200px; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .alt-size                { font-weight: bold; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .badge                   { width: 75%; background-color: #17a2b8; color: #fff; display: inline-block; padding: .75em .4em; font-weight: 700; line-height: 1; text-align: center; white-space: nowrap; vertical-align: baseline; border-radius: .25rem; }\n' +
                                                                        '#TorrentGridControls                               { background: #d3dde7; text-align: center; margin: 0 14px 20px 14px; padding: 10px; border: 1px solid #9faabc; }\n' +
                                                                        '#TorrentGridControls h3                            { margin: 0 0 10px 0; }\n' +
                                                                        '#TorrentGridControls span                          { margin: 0 5px; }\n' +
                                                                        // Grid Templates Areas --------------------------------------------
                                                                        '#TorrentGrid .grid-lista2 .thumb                   { grid-area: thumb; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .file                    { grid-area: file; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .mldl                    { grid-area: mldl; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .added                   { grid-area: added; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .size                    { grid-area: size; margin-bottom: 10px; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .seeders                 { grid-area: seeders; justify-self: right; margin-right: 5px; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .leechers                { grid-area: leechers; justify-self: left; margin-left: 5px; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .comments                { grid-area: comments; margin-top: 10px; }\n' +
                                                                        '#TorrentGrid .grid-lista2 .uploader                { grid-area: uploader; margin-top: 10px; }\n' +
                                                                        '</style>');
        if (isTorrentMagnetLinksScriptActive)
        {
            $("#TorrentGrid").prepend('<style>#TorrentGrid .grid-lista2                                                     { grid-template-areas: "thumb thumb"\n' +
                                                                                                                                                    '"file file"\n' +
                                                                                                                                                    '"mldl mldl"\n' + 
                                                                                                                                                    '"added added"\n' +
                                                                                                                                                    '"size size"\n' +
                                                                                                                                                    '"seeders leechers"\n' +
                                                                                                                                                    '"comments uploader"; }\n' +
                                                    '</style>');
        }
        else
        {
            $("#TorrentGrid").prepend('<style>#TorrentGrid .grid-lista2                                                     { grid-template-areas: "thumb thumb"\n' +
                                                                                                                                                    '"file file"\n' +
                                                                                                                                                    '"added added"\n' +
                                                                                                                                                    '"size size"\n' +
                                                                                                                                                    '"seeders leechers"\n' +
                                                                                                                                                    '"comments uploader"; }\n' +
                                                    '</style>');
        }
        // need to create bools that identify when the torrent and magnet links and various tweaks scripts are active
        // also need to create unique grid template areas above
        // Creates the grid
        $.each($(".lista2t .lista2"), function(index) {
            var parentIndex = index + 1;
            $("#TorrentGrid").append("<div class=\"grid-lista2\"/>");
            $.each($(this).find("td"), function(index) {
                var childIndex = index + 1;
                var target = $(this).closest("table").prev().find("div.grid-lista2:nth-of-type("+parentIndex+")");
                target.append("<div class=\"lista\"/>");
                var currentElement = target.find(".lista:nth-of-type("+childIndex+")").eq(0);
                currentElement.html($(this).html());
                if (isTorrentMagnetLinksScriptActive)
                {
                    switch (childIndex) {
                        case 1: // thumbnail TD
                            currentElement.addClass("thumb");
                            break;
                        case 2: // file TD
                            currentElement.addClass("file");
                            currentElement.find("a:first-child").addClass("alt-layout");
                            currentElement = currentElement.find("a:first-child");
                            var fileName = currentElement.text().replace(/\./g," ");
                            currentElement.text(fileName);
                            break;
                        case 3: // DL ML TD - belongs to torrent and magnet links script
                            currentElement.addClass("mldl alt-darker");
                            currentElement.prepend("DL ML: ");
                            break;
                        case 4: // Added TD
                            currentElement.addClass("added alt-deco");
                            currentElement.prepend("Added: ");
                            break;
                        case 5: // Size TD
                            currentElement.addClass("size alt-size");
                            currentElement.prepend("Size: ");
                            break;
                        case 6: // Seed TD
                            currentElement.addClass("seeders badge");
                            currentElement.prepend("Seeds: ");
                            currentElement.find("font").removeAttr("color");
                            break;
                        case 7: // Leecher TD
                            currentElement.addClass("leechers badge");
                            currentElement.prepend("Leechers: ");
                            currentElement.find("font").removeAttr("color");
                            break;
                        case 8: // Comments TD
                            currentElement.addClass("comments");
                            currentElement.prepend("# Comments: ");
                            break;
                        case 9: // Uploader TD
                            currentElement.addClass("uploader");
                            currentElement.prepend("# Uploader: ");
                            break;
                    }
                } else {
                    switch (childIndex) {
                        case 1: // thumbnail TD
                            currentElement.addClass("thumb");
                            break;
                        case 2: // file TD
                            currentElement.addClass("file");
                            currentElement.find("a:first-child").addClass("alt-layout");
                            currentElement = currentElement.find("a:first-child");
                            fileName = currentElement.text().replace(/\./g," ");
                            currentElement.text(fileName);
                            break;
                        case 3: // Added TD
                            currentElement.addClass("added alt-deco");
                            currentElement.prepend("Added: ");
                            break;
                        case 4: // Size TD
                            currentElement.addClass("size alt-size");
                            currentElement.prepend("Size: ");
                            break;
                        case 5: // Seed TD
                            currentElement.addClass("seeders badge");
                            currentElement.prepend("Seeds: ");
                            currentElement.find("font").removeAttr("color");
                            break;
                        case 6: // Leecher TD
                            currentElement.addClass("leechers badge");
                            currentElement.prepend("Leechers: ");
                            currentElement.find("font").removeAttr("color");
                            break;
                        case 7: // Comments TD
                            currentElement.addClass("comments");
                            currentElement.prepend("# Comments: ");
                            break;
                        case 8: // Uploader TD
                            currentElement.addClass("uploader");
                            currentElement.prepend("# Uploader: ");
                            break;
                    }
                }
            });
        });
        // Sorting Buttons
        $("<div id=\"TorrentGridControls\"/>").insertBefore("#TorrentGrid");
        $.each($(".lista2t tbody tr:first-child td"), function(index) {
            var content = $(this).html();
            if (content.match("tdlinkfull3")) {
                var href = $(this).find(".tdlinkfull3").attr("href");
                var btnID = href.substring(href.lastIndexOf("order=")+6,href.indexOf("&by="));
                var buttonName = btnID.charAt(0).toUpperCase() + btnID.substr(1).toLowerCase();
                if (buttonName === "Data") {
                    buttonName = "Added";
                }
                $("#TorrentGridControls").append("<span href='" + href + "' class='btn btn-primary jQGridSort'>Sort " + buttonName + "</span>");
            }
        });
        // Sorting title logic
        var url = window.location.href;
        var sortingBy = url.substring(url.lastIndexOf("&by=")+4);
        var btnID = url.substring(url.lastIndexOf("order=")+6,url.indexOf("&by="));
        if (btnID === "https") {
            $("#TorrentGridControls").prepend("<h3>Not Sorted</h3>");
        } else {
            var buttonName = btnID.charAt(0).toUpperCase() + btnID.substr(1).toLowerCase();
            if (buttonName === "Data") {
                buttonName = "Added";
            }
            $("#TorrentGridControls").prepend("<h3>" + sortingBy + " Sorted by " + buttonName + "</h3>");
        }
        // Event trigger for sorting buttons
        $(document).on("click", ".jQGridSort", function (){
            location.href = $(this).attr("href");
        });
        // Removes the list from the DOM
        $(".lista2t").remove();
    }
});