Greasy Fork is available in English.

Brazen Framework - Paginator

Client side customized pagination for Brazen user scripts framework

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.org/scripts/424499/1847309/Brazen%20Framework%20-%20Paginator.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
brazenvoid
版本
3.0.1
创建于
2021-04-04
更新于
2026-06-09
大小
6.8 KB
许可证
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

Classic paginated search UIs where client-side filters hide most tiles. Not a substitute for infinite-scroll-only sites (though observer-based compliance still applies).


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.


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

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

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).