Main class of the Brazen user scripts framework
Version vom
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.sleazyfork.org/scripts/416105/1847278/Brazen%20Framework%20-%20Framework.js
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.
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 |
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.
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.
Requires @grant GM_download on the application script.
this._addDownload(mediaElement, folder, filename, removeMediaOnSuccess?)
downloadsDelay.removeMediaOnSuccess on pictures: captures URL from src, removes element immediately (see media-downloads.spec.md).Override _handleDownloadFailed / _handleDuplicateDownloadSkipped for site UX.
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).
this._setupPaginator(() => IS_SEARCH_PAGE, { /* BrazenPaginator config */ })
this._setupSubscriptionLoader() // then configure loader in _onBeforeUIBuild
See BrazenPaginator.md, BrazenSubscriptionsLoader.md.
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.
Framework modules live in the base-scripts/ repo (v1.x). When you add breaking API changes:
@require URLs if needed..spec.md.Apps in published-user-scripts/ are separate repos/projects.