Brazen Framework - Paginator

Client side customized pagination for Brazen user scripts framework

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/424499/1875067/Brazen%20Framework%20-%20Paginator.js

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

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

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ć!)

Advertisement:

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ć!)

Advertisement:

Autor
brazenvoid
Wersja
3.0.1
Utworzono
04-04-2021
Zaktualizowano
09-06-2026
Rozmiar
6,8 KB
Licencja
GPL-3.0-only

Brazen Framework — Paginator (developer guide)

Optional. After filtering, if too few compliant tiles remain, fetch and append subsequent search pages until a limit or the last page.

Greasy Fork: Paginator · Requires: Utilities · @require before Framework core


When to use / when not to use

  • Use this module when the site is truly page-based and client-side filters often hide most results, leaving “too few” visible items on the current page.
  • Don’t use this as a replacement for infinite scroll. Infinite scroll is handled by the framework’s list observation; paginator is for fetching the next page HTML and concatenating.
  • Don’t use this for ‘auto-next’ navigation. That’s a separate pattern (see bottom).

Quick start (setup via framework)

this._setupPaginator(
  () => IS_SEARCH_PAGE,  // enableCondition
  {
    itemListSelector: '#video-list',
    paginationWrapper: '.pagination',
    lastPageUrl: 'https://example.com/search?page=99',
    onGetPageNoFromUrl: (pageUrl, paginator) => /* parse int */,
    onGetPageUrlFromPageNo: (pageNo, paginator) => /* build url */,
    onGetPaginationElementForPageNo: (pageNo, paginator) => /* jQuery link */,
  },
)

_setupPaginator also registers Configuration Manager fields:

Constant Display name Range Role
CONFIG_PAGINATOR_THRESHOLD Pagination Threshold 1–1000 Minimum compliant items before stopping
CONFIG_PAGINATOR_LIMIT Pagination Limit 1–50 Max additional pages to merge beyond current

configuration.itemSelectors is set from framework itemSelectors automatically.


Features

Threshold/limit-driven pagination

What it does: After each compliance pass, the paginator checks how many compliant items remain (items without .brazen-noncompliant-item). If the count is below a user-configured threshold, it fetches the next page(s) and appends their items into the current list.

Framework _setupPaginator also registers Configuration Manager fields:

Constant Display name Range Role
CONFIG_PAGINATOR_THRESHOLD Pagination Threshold 1–1000 Minimum compliant items before stopping
CONFIG_PAGINATOR_LIMIT Pagination Limit 1–50 Max additional pages to merge beyond current

Configuration keys (PaginatorConfiguration)

Key Required Role
itemListSelector yes Container selector for .load() and tile insertion
paginationWrapper yes Site pagination root (length check gates run)
lastPageUrl yes URL of final page — used to compute _lastPageNo
onGetPageNoFromUrl yes (pageUrl, paginator) => number
onGetPageUrlFromPageNo yes (pageNo, paginator) => string
onGetPaginationElementForPageNo yes (pageNo, paginator) => JQuery
itemSelectors set by framework Tile selector; defaults to app itemSelectors

Public API

Method Role
initialize() Parse current/last page from URLs; create #brazen-paginator-sandbox; cache _targetElement
run(threshold, limit) Entry point — may fetch next page
onAfterPagination(handler) (paginator) => void after UI conform step
getCurrentPageNo() Current page from location
getLastPageNo() From lastPageUrl
getPaginatedPageNo() Highest page merged so far
getItemListSelector() Config selector
getPaginationWrapper() Config wrapper
getPageNoFromUrl(url) Delegates to callback
getPageUrlFromPageNo(n) Delegates to callback
getPaginationElementForPageNo(n) Delegates to callback

Run behaviour (how run(threshold, limit) decides to fetch)

run(threshold, limit) executes only when paginationWrapper.length and threshold are truthy.

Loop condition (all must hold):

  1. _paginatedPageNo < _lastPageNo
  2. limit > 0 and (_paginatedPageNo - _currentPageNo) < limit
  3. Compliant tile count < threshold (tiles without .brazen-noncompliant-item)

When true:

  • Increment _paginatedPageNo
  • Sandbox .load(nextUrl + ' ' + itemListSelector)
  • Append sandbox itemSelectors after last compliant tile in list
  • Set _pageConcatenated = true

When false: _conformUIToNewPaginatedState() updates pagination links (merged range label start-end, prune superseded links).

Framework integration:

  • initialize() during init() if paginator configured.
  • run(threshold, limit) after each compliance pass and when new nodes observed on paginated list.
  • Uses CLASS_NON_COMPLIANT_ITEM from Framework core for compliant count.

UI mutation (what the user sees)

After concatenation, current page link text becomes {currentPageNo}-{paginatedPageNo}. Subsequent page links are removed or retargeted depending on whether the merged range ends at the last page.


Related pattern

Auto next page: navigate when all items on a page are filtered — implement in _onAfterComplianceRun using site next-link (independent of this module).


Public API reference (index)

  • Lifecycle: initialize, run
  • Events: onAfterPagination
  • Introspection: getCurrentPageNo, getLastPageNo, getPaginatedPageNo
  • Config accessors: getItemListSelector, getPaginationWrapper
  • Callback delegates: getPageNoFromUrl, getPageUrlFromPageNo, getPaginationElementForPageNo