Brazen Framework - Paginator

Client side customized pagination for Brazen user scripts framework

このスクリプトは単体で利用できません。右のようなメタデータを含むスクリプトから、ライブラリとして読み込まれます: // @require https://update.greasyfork.org/scripts/424499/1875067/Brazen%20Framework%20-%20Paginator.js

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

Advertisement:

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

Advertisement:

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
作者
brazenvoid
バージョン
3.0.1
作成日
2021/04/04
更新日
2026/06/09
大きさ
6.8KB
ライセンス
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