Brazen Framework - Framework

Main class of the Brazen user scripts framework

La data de 09-06-2026. Vezi ultima versiune.

Acest script nu ar trebui instalat direct. Aceasta este o bibliotecă pentru alte scripturi care este inclusă prin directiva meta a // @require https://update.sleazyfork.org/scripts/416105/1847278/Brazen%20Framework%20-%20Framework.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Autor
brazenvoid
Versiune
7.2.1
Creat
14-11-2020
Actualizat
09-06-2026
Size
46 KB
Licență
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.

Technical reference: BrazenFramework.spec.md · Patterns: pattern-specs/

Greasy Fork: 416105 · Current version: see @version in BrazenFramework.js.


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. ehentai td.gl2e)

See page-detection-and-lifecycle.spec.md.


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 (rule34xxx tag blacklist).

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

See item-attributes-and-compliance.spec.md.


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 (see media-downloads.spec.md).

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.

References: rule34xxx (post id), ehentai (full save path).


Optional modules

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

See BrazenPaginator.md, BrazenSubscriptionsLoader.md.


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

See ui-panel-composition.spec.md, BrazenViewLayer.md.


Publishing

Framework modules live in the base-scripts/ repo (v1.x). When you add breaking API changes:

  1. Bump the module version and publish to Greasy Fork.
  2. Bump dependent apps and their @require URLs if needed.
  3. Document breaking changes in the module’s .spec.md.

Apps in published-user-scripts/ are separate repos/projects.