Fixed sort:score Button

Fixed version of the sort:score button

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Fixed sort:score Button
// @namespace   Violentmonkey Scripts
// @version     1
// @author      usnkw, hetisnietgay
// @description Fixed version of the sort:score button
// @license MIT
// @match       *://rule34.xxx/*
// ==/UserScript==
// Don't need so many comments, it's clear what we're doing

// Removed on ready/load call since grease/violent/tampermonkey
// scripts are executed on DOMContentLoaded

(() => {
    'use strict';

     // Create our button
    var newButton = document.createElement("Button");
    newButton.innerHTML = "sort:score";
    newButton.style.cursor = "pointer";

    // Better not to use inline events
    newButton.addEventListener('click', (e) => {

        var searchField = document.getElementsByName("tags")[0];

        if (searchField.value.toLowerCase().indexOf("sort:score") == -1) {
            searchField.value += " sort:score"
        }

        e.preventDefault();
    });

    // Search box has class awesomplete, add our button after it
    document.getElementsByClassName("awesomplete")[0].appendChild(newButton);

})();