Greasy Fork is available in English.

Better RARBG search - search by size, descending; add quick search box

2022-01-30, 16:12:23

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Better RARBG search - search by size, descending; add quick search box
// @namespace   Violentmonkey Scripts
// @match       *://rarbg2021.org/*
// @grant       none
// @version     1.0
// @author      -
// @description 2022-01-30, 16:12:23
// ==/UserScript==



// add quick-search form so you can search from any page

$("form[action='/login']").ready(function () {
  loginTds = $("form[action='/login']").parents("tr").children()
  const quicksearchTd = loginTds[loginTds.length - 1]
  
  const formHtml = `
<form action="/torrents.php" method="get" style="width: 500px" id="quickSearchTorrent">
  <input x-webkit-speech="x-webkit-speech" type="text" name="search" id="quicksearchinput" style="width: 440px;" maxlength="60" value="" autocomplete="on" placeholder="Search Torrents" />
  <input type="hidden" name="order" value="size" />
  <input type="hidden" name="by" value="DESC" />
</form>
  `  
  quicksearchTd.innerHTML = formHtml


  const loc = window.location.toString()

  if(loc.startsWith("https://rarbg2021.org/torrents.php") || loc.startsWith("http://rarbg2021.org/torrents.php")) {
    $("form#searchTorrent").ready(function () {
      // improvements to search form
      $("form#searchTorrent").append("<input type='hidden' name='order' value='size' />") // sort by size
      $("form#searchTorrent").append("<input type='hidden' name='by' value='DESC' />") // sort descending

      // Note that "sort descending" is the default sorting order, so if the "by" variable is not included,
      // that's the sorting order you will get. RARBG actually had to make this broken on purpose with
      // extra code. They did it in order to get more ad revenue. This is such bullshit!!!!

      // showhideadvsearch('hide'); // hide the advanced search (category selection) so you don't have to scroll
      // note if you hide the advanced search, the category selection gets cleared, which SUCKS!
      // I might fix this at some point. RARBG explicitly clears the flags. I have disabled it for now.

      // scroll to the results. This has to happen after the quick search form is added and after the category selection gets hidden.
      $("table.lista2t").ready(function () {
        $("table.lista2t")[0].scrollIntoView()
      })
    })
  }
})