Brazen Framework - Framework

Main class of the Brazen framework

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.sleazyfork.org/scripts/416105/1847198/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!)

Author
brazenvoid
Version
7.1.1
Created
2020-11-14
Updated
2026-06-09
Size
36.7 KB
License
GPL-3.0-only

Requires

Dependency Required
BrazenUtilities.js yes
BrazenViewLayer.js yes
BrazenConfigurationManager.js yes
BrazenItemAttributeResolver.js yes (except legacy apps like xnxx)
BrazenPaginator.js optional
BrazenSubscriptionsLoader.js optional
jQuery yes

Load position: The core module — loads last among the framework modules, before the application script.

Runtime

Grants none (apps may grant GM_addStyle, GM_download)

Provides

Class: BrazenFramework (abstract — applications extend it)

Constants:

  • Item identification classes: CLASS_COMPLIANT_ITEM, CLASS_NON_COMPLIANT_ITEM
  • Paginator config keys: CONFIG_PAGINATOR_LIMIT ('Pagination Limit'), CONFIG_PAGINATOR_THRESHOLD ('Pagination Threshold')
  • Preset filter keys: FILTER_DURATION_RANGE, FILTER_PERCENTAGE_RATING_RANGE, FILTER_SUBSCRIBED_VIDEOS, FILTER_TAG_BLACKLIST, FILTER_TEXT_BLACKLIST, FILTER_TEXT_SEARCH, FILTER_TEXT_SANITIZATION, FILTER_TEXT_WHITELIST, FILTER_UNRATED
  • Option flags: OPTION_ENABLE_TEXT_BLACKLIST, OPTION_ENABLE_TAG_BLACKLIST, OPTION_ALWAYS_SHOW_SETTINGS_PANE, OPTION_DISABLE_COMPLIANCE_VALIDATION
  • Item attribute names: ITEM_NAME, ITEM_PROCESSED_ONCE
  • Store key: STORE_SUBSCRIPTIONS ('Account Subscriptions')
  • Misc: ICON_RECYCLE

Constructor config keys: scriptPrefix, itemListSelectors, itemSelectors, itemNameSelector, itemLinkSelector, itemDeepAnalysisSelector, itemSelectionMethod, itemWrapperResolver, tagSelectorGenerator, isUserLoggedIn, requestDelay, downloadsDelay, doItemCompliance, trackComplianceRules

Filter helpers: _addItemBlacklistFilter, _addItemWhitelistFilter, _addItemTextSearchFilter, _addItemTextSanitizationFilter, _addItemTagBlacklistFilter, _addItemDurationRangeFilter, _addItemPercentageRatingRangeFilter, _addItemTagHighlights, _addSubscriptionsFilter, _addItemComplianceFilter, _addItemComplexComplianceFilter

Lifecycle — init() order (only if _onValidateInit() is truthy):

  1. configurationManager.initialize() (loads localStorage, sets up cross-tab sync).
  2. Registers built-in processedOnce attribute, and name attribute only if itemNameSelector !== ''.
  3. paginator.initialize() if a paginator was set up.
  4. Runs _onBeforeUIBuild queue.
  5. Unless _disableUI: builds the panel (createSettingsSection().append(this._userInterface)), embeds it, runs _onAfterUIBuild, then updateInterface().
  6. _validateCompliance(true) — first compliance run.
  7. Runs _onAfterInitialization queue.

Compliance pipeline:

  • _validateCompliance(firstRun) — on the first run, attaches a ChildObserver to each itemListSelectors node so items appended later (infinite scroll, AJAX) are complied automatically (fromObserver); integrates the paginator if present. Re-runs reset statistics first.
  • _complyItemsList(list, fromObserver) — selects items (children or find per itemSelectionMethod), fades them to opacity:0.75; on each item's first hit: sanitizes the name node (if enabled), resolves attributes, runs _onFirstHitBeforeCompliance; then _complyItem; then _onFirstHitAfterCompliance (once) and marks processedOnce. Ends with statistics.updateUI() + _onAfterComplianceRun.
  • _complyItem(item) — skips when doItemCompliance returns false or OPTION_DISABLE_COMPLIANCE_VALIDATION is on; runs the whitelist gate (_validateItemWhiteList), then _onBeforeCompliance, then walks _complianceFilters (validate → comply), short-circuiting on first failure, recording each result; comply callbacks may return {complies, rule?} when trackComplianceRules is enabled; finally shows/hides the item and clears opacity.
  • _getComplianceRuleReport() / _showComplianceRulesModal() — opt-in per-rule hide diagnostics (requires trackComplianceRules: true). Modal lists only rules that hid items on the current pass, grouped by filter. Override _canRemoveComplianceRule(filterKey, ruleLabel) / _removeComplianceRule(filterKey, ruleLabel) to show a Remove button per row (rule34xxx uses this for exact tag-blacklist lines).

Behaviours provided automatically (don't re-implement):

  • Compliance CSS classes: default _onItemShow/_onItemHide add/remove CLASS_COMPLIANT_ITEM/CLASS_NON_COMPLIANT_ITEM (via itemWrapperResolver) and show/hide. Override only for special wrapping (see ehentai's td.gl2e).
  • _addItemComplianceFilter(key, action=null) — when action is omitted/an attribute-name string, the comply logic is derived from the config field type: checkboxes→includes, flag→boolean, radios→equality, range→Validator.isInRange; text/ruleset require an explicit callback. The enable check defaults to generateValidationCallback(key) (flag/radios/select→truthy, checkboxes/ruleset/text→length, number→>0, range→min>0||max>0).
  • Statistics count removals: _statistics.record(key, complies) increments only when an item fails, and totals feed createStatisticsFormGroup(key) labels.
  • Downloads: _addDownload truncates the folder to 120 chars, replaces illegal ‹›:"/\|?* chars with -, and uses GM_download with conflictAction:'uniquify'.

Hooks: _onValidateInit, _onBeforeUIBuild, _onAfterUIBuild, _onAfterInitialization, _onFirstHitBeforeCompliance, _onBeforeCompliance, _onFirstHitAfterCompliance, _onAfterComplianceRun, _onItemHide (single fn), _onItemShow (queue), _canRemoveComplianceRule, _removeComplianceRule. (_onUIBuild, _onGetItemLists, _onGetItemName referenced by older apps.)

Optional setup: _setupPaginator(), _setupSubscriptionLoader(), download queue via _addDownload / GM_download

Purpose

Shared framework for site search filters, settings UI, compliance hiding, statistics, and cross-tab config sync.