Derpibooru - Sort-by-Score Button

Adds a button to automatically sort by score after a search. Also, remove pointless scope stuff from URLs.

Verze ze dne 07. 01. 2019. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Derpibooru - Sort-by-Score Button
// @namespace   Selbi
// @version     2
// @include     http*://*derpiboo.ru/tags*
// @include     http*://*derpibooru.org/tags*
// @include     http*://*derpiboo.ru/search*
// @include     http*://*derpibooru.org/search*
// @grant       none
// @description Adds a button to automatically sort by score after a search. Also, remove pointless scope stuff from URLs.
// ==/UserScript==

const INDEX_SORTBYSCORE = 2;
const INDEX_DESCENDING = 0;

var sortButtonIcon = document.createElement("i");
sortButtonIcon.classList = "fas fa-sort-amount-down";
Object.assign(sortButtonIcon.style, {
  width: "28px",
  textAlign: "center"
});

var sortButton = document.createElement("a");
sortButton.classList = "header__search__button";
sortButton.title = "Sort by descending score";
sortButton.onclick = function() {
  document.querySelector("select.input--separate-left:nth-child(3)").selectedIndex = INDEX_SORTBYSCORE;
  document.querySelector("#sd").selectedIndex = INDEX_DESCENDING;
  
  document.querySelector(".field > input.button:first-child").click();
};

sortButton.appendChild(sortButtonIcon);
document.querySelector(".header__search").appendChild(sortButton);