Derpibooru - Sort-by-Score Button

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

Από την 07/01/2019. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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);