Client side customized pagination for Brazen user scripts framework
Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greasyfork.org/scripts/424499/1875067/Brazen%20Framework%20-%20Paginator.js
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
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.
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 |
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 |
| 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(threshold, limit) decides to fetch)run(threshold, limit) executes only when paginationWrapper.length and threshold are truthy.
Loop condition (all must hold):
_paginatedPageNo < _lastPageNolimit > 0 and (_paginatedPageNo - _currentPageNo) < limit< threshold (tiles without .brazen-noncompliant-item)When true:
_paginatedPageNo.load(nextUrl + ' ' + itemListSelector)itemSelectors after last compliant tile in list_pageConcatenated = trueWhen 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.CLASS_NON_COMPLIANT_ITEM from Framework core for compliant count.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.
Auto next page: navigate when all items on a page are filtered — implement in _onAfterComplianceRun using site next-link (independent of this module).
initialize, runonAfterPaginationgetCurrentPageNo, getLastPageNo, getPaginatedPageNogetItemListSelector, getPaginationWrappergetPageNoFromUrl, getPageUrlFromPageNo, getPaginationElementForPageNo