Brazen Framework - Framework

Main class of the Brazen framework

Este script não deve ser instalado diretamente. Este script é uma biblioteca de outros scripts para incluir com o diretório meta // @require https://update.sleazyfork.org/scripts/416105/1847282/Brazen%20Framework%20-%20Framework.js

Você precisará instalar uma extensão como Tampermonkey, Greasemonkey ou Violentmonkey para instalar este script.

Você precisará instalar uma extensão como Tampermonkey para instalar este script.

Você precisará instalar uma extensão como Tampermonkey ou Violentmonkey para instalar este script.

Você precisará instalar uma extensão como Tampermonkey ou Userscripts para instalar este script.

Você precisará instalar uma extensão como o Tampermonkey para instalar este script.

Você precisará instalar um gerenciador de scripts de usuário para instalar este script.

(Eu já tenho um gerenciador de scripts de usuário, me deixe instalá-lo!)

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar uma extensão como o Stylus para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

Você precisará instalar um gerenciador de estilos de usuário para instalar este estilo.

(Eu já possuo um gerenciador de estilos de usuário, me deixar fazer a instalação!)

Autor
brazenvoid
Versão
7.2.1
Criado
14/11/2020
Atualizado
09/06/2026
Tamanho
46 KB
Licença
GPL-3.0-only

Brazen Framework — Core (developer guide)

Extend BrazenFramework to build a site userscript. The core owns init order, compliance hiding, filter registration, download queueing, and shared constants.

Greasy Fork: this script · Changelog: append the Changelog section from the matching changelog file when publishing · Sibling modules: see Utilities, View Layer, Configuration Manager, Item Attributes Resolver, optional Paginator / Subscriptions Loader.


Constructor config

Pass a single object to super({ ... }):

Key Purpose
scriptPrefix Prefix for localStorage keys and default ledger storage key
itemListSelectors jQuery selector(s) for lists observed for new tiles
itemSelectors Tile selector inside each list
itemNameSelector Title node for text filters; '' disables built-in name attribute
itemLinkSelector Link used by Item Attributes Resolver for deep fetch
itemDeepAnalysisSelector Root on detail page for deep attributes
itemSelectionMethod 'children' or 'find' — how tiles are collected
itemWrapperResolver (item) => wrapper for show/hide and CSS classes
tagSelectorGenerator Builds tag selectors for highlight filters
requestDelay Throttle between deep attribute fetches (ms)
downloadsDelay Pause between GM_download queue items (ms)
doItemCompliance (item) => boolean — skip compliance for some tiles
trackComplianceRules true enables per-rule hide diagnostics modal
downloadDuplicateLedger Optional duplicate skip (v7.2.0+); see below

Lifecycle

init() runs only when _onValidateInit() is truthy (return false to skip entirely, e.g. small popup windows).

configurationManager.initialize()
→ register built-in item attributes
→ paginator.initialize() (if configured)
→ _onBeforeUIBuild[] 
→ build #bv-ui (unless _disableUI)
→ _onAfterUIBuild[]
→ _validateCompliance(firstRun) + ChildObserver on lists
→ _onAfterInitialization[]

Hook arrays (push callbacks in the subclass constructor):

Hook Typical use
_onValidateInit Abort init on wrong page or window size
_onBeforeUIBuild Register filters, page-specific GM_addStyle, auto-download
_onAfterUIBuild Patch DOM, attach userScript to panel, custom widgets
_onAfterInitialization Late wiring after first compliance pass
_onFirstHitBeforeCompliance Inject tags/attributes before filters run
_onBeforeCompliance Per-item pre-filter
_onFirstHitAfterCompliance Once per tile after first compliance
_onAfterComplianceRun After a full list pass
_onItemShow / _onItemHide Default adds compliance classes; override for special layout (e.g. table rows where the tile is nested inside <td>)

Detect page type in your app (URL/DOM flags), then push hooks in the constructor before init().


Compliance and filters

The framework hides non-compliant tiles and records statistics (counts = items removed).

Register filters in the constructor:

this._addItemTagBlacklistFilter(ITEM_TAGS, /* ... */)
this._addItemComplianceFilter('My Flag', 'myAttribute')  // derived from field type
this._addItemComplexComplianceFilter(key, validateFn, complyFn)
  • OPTION_DISABLE_COMPLIANCE_VALIDATION — master bypass (Disable All Filters).
  • trackComplianceRules: true — enables _showComplianceRulesModal(); override _canRemoveComplianceRule / _removeComplianceRule for removable rows.

Do not re-implement default show/hide unless the site wraps tiles unusually.


Downloads

Requires @grant GM_download on the application script.

this._addDownload(mediaElement, folder, filename, removeMediaOnSuccess?)
  • Serial queue with downloadsDelay.
  • Sanitizes path segments; folder truncated to 120 chars.
  • removeMediaOnSuccess on pictures: captures URL from src, removes element immediately.

Override _handleDownloadFailed / _handleDuplicateDownloadSkipped for site UX.


Download duplicate ledger (v7.2.0+)

Optional constructor block for “already queued this save” without scanning disk:

downloadDuplicateLedger: {
  storageKey: 'myapp-download-registry',
  primaryField: 'postIds',           // or 'paths', etc.
  legacyIdFields: ['mediaKeys'],     // migration merge on load
  isValidId: (value) => /^\d+$/.test(String(value).trim()),
  getDownloadId: (item) => QUERY_PARAMS.get('id') || null,
}

Also requires @grant GM_getValue and @grant GM_setValue.

Behaviour Detail
Enable flag Skip Duplicate Downloads (OPTION_ENABLE_DOWNLOAD_DUPLICATE_LEDGER), registered automatically; default on
User tooltip OPTION_ENABLE_DOWNLOAD_DUPLICATE_LEDGER_HELP — ledger remembers script storage, not disk
When on _wrapDownloadTask skips before GM_download; conflictAction: 'overwrite' if file exists but ledger missed
When off Normal downloads; stored ids kept; conflictAction: 'uniquify' (legacy)
UI Mount createElement(OPTION_ENABLE_DOWNLOAD_DUPLICATE_LEDGER) on your downloads tab
Overrides _getDownloadDuplicateLedgerId, _handleDuplicateDownloadSkipped, _handleDownloadFailed

Never use uniquify as the primary duplicate strategy for ledger apps — duplicates should be skipped in the ledger, not renamed on disk.

Typical id strategies: numeric post id from the URL; full resolved save path (folder/filename); or another stable string your app can derive at enqueue time.


Optional modules

this._setupPaginator(() => IS_SEARCH_PAGE, { /* BrazenPaginator config */ })
this._setupSubscriptionLoader()  // then configure loader in _onBeforeUIBuild

See Paginator, Subscriptions Loader.


UI composition

Build this._userInterface as an array of nodes from this._uiGen (a BrazenViewLayer instance):

this._userInterface = [
  this._uiGen.createTabsSection(['Filters', 'Downloads'], [
    this._uiGen.createTabPanel('Filters', true).append([
      this._configurationManager.createElement(FILTER_TAG_BLACKLIST),
    ]),
    // ...
  ]),
]

Bottom section: statistics groups, page buttons, Apply/Save/Reset via _createSettingsFormActions().

Panel details: View Layer developer section on that listing.


Publishing

When you ship a new framework version on Greasy Fork:

  1. Bump @version in the script header and publish.
  2. Bump dependent apps and their @require URLs if needed.
  3. Append release notes to the Changelog section on the listing (keep in sync with the changelog source file in the repo).

Publish framework modules before apps that depend on new APIs.