StartPage.com - Number Results

Number search results on StartPage.com

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name           StartPage.com - Number Results
// @namespace      tag:[email protected],2012:monkey
// @description    Number search results on StartPage.com
// @match          https://*.startpage.com/*/search*
// @author         r-a-y
// @version        1.2.1
// @license        GPL v3
// ==/UserScript==

let results = document.querySelectorAll( '.result' ), pageNumber, numItems;

if ( results.length ) {
  results = document.querySelectorAll( '.result h2' );
  pageNumber = document.querySelector( '.pagination form[aria-label^=current] button' );

  if ( pageNumber ) {
    pageNumber = pageNumber.textContent;
  } else {
    pageNumber = 1;
  }

  // Deal with custom results per page.
  if ( results.length % 20 === 0 ) {
    numItems = 20;
  } else {
    numItems = 10;
  }

  // On last page, default to 20.
  if ( ! document.querySelector( '.pagination form[aria-label^=current] + form' ) ) {
    numItems = 20;
  }
}

// DOM inject.
for ( let i = 0, len = results.length; i < len; ++i ) {
  let newContent;
  let newSpan = document.createElement( "span" );
  newSpan.setAttribute( "style", "float:left; font-weight:600; font-size:1em; display:inline-block; margin-right:5px;" );

  newContent = document.createTextNode( ( ( pageNumber - 1 ) * numItems + i + 1 ) + ". ");

  newSpan.appendChild( newContent );

  results[i].insertBefore( newSpan, results[i].firstChild );
}