Brazen Framework - Utilities

Utilities and helpers for Brazen user scripts framework

이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greatest.deepsurf.us/scripts/375557/1847304/Brazen%20Framework%20-%20Utilities.js을(를) 사용하여 포함하는 라이브러리입니다.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

작성자
brazenvoid
버전
4.1.0
생성일
2018-12-15
갱신일
2026-06-09
크기
13.1KB
라이선스
GPL-3.0-only

Brazen Framework — Utilities (developer guide)

Foundation module: shared helpers with no site logic. Every other Brazen Framework module depends on this script.

Greasy Fork: Utilities · Loads first among framework modules (after jQuery).


Module constants

Constant Value Use
REGEX_LINE_BREAK /\r?\n/g Split textarea rules (Configuration Manager rulesets)
REGEX_PRESERVE_NUMBERS /\D/g Strip non-digits from strings

ChildObserver

Fluent MutationObserver wrapper for childList add/remove on a single node.

Method Returns Description
ChildObserver.create() ChildObserver Factory
observe(node) this Attach to a DOM Node
onNodesAdded(handler) this (nodes, previousSibling, nextSibling, target) => void
onNodesRemoved(handler) this Same callback signature
pauseObservation() disconnect()
resumeObservation() Re-attach with same options

The framework uses ChildObserver on each itemListSelectors entry so infinite scroll and AJAX lists receive compliance without manual hooks. Use directly only for non-compliance DOM watching.

ChildObserver.create()
  .onNodesAdded((nodes) => { /* ... */ })
  .observe(document.querySelector('#results'))

LocalStore

localStorage wrapper with defaults, change callbacks, and optional nested-object serialization.

Constructor: new LocalStore(key, defaultsObject)

Method Returns Description
get() Object Parse stored JSON; if empty, calls restoreDefaults()
save(data) this JSON.stringify + setItem; fires onChange
delete() this removeItem
restoreDefaults() Object Writes defaults and sets wereDefaultsSet() flag
onChange(handler) this (storeObject) => void after every save
wereDefaultsSet() boolean true when last get() fell back to defaults

Nested objects: If stored JSON has top-level arrays, objects, and properties keys, get() uses Utilities.objectFromJSON for round-trip of nested arrays/objects. Plain JSON objects are returned as parsed.

Configuration Manager wraps two LocalStore instances: {scriptPrefix}settings and {scriptPrefix}settings-id.


SelectorGenerator

Builds prefixed kebab-case selectors for generated UI fragments.

Constructor: new SelectorGenerator(selectorPrefix) — typically scriptPrefix from the app.

Method Returns Example
getSelector(selector) string prefix + selector
getSettingsInputSelector(settingName) string {prefix}{kebab-name}-setting
getSettingsRangeInputSelector(name, getMin) string {prefix}{kebab-name}-min-setting or -max-setting
getStatLabelSelector(statisticType) string Used as element id for stat labels

StatisticsRecorder and View Layer stat widgets use getStatLabelSelector.


StatisticsRecorder

Tracks per-filter removal counts and updates DOM labels.

Constructor: new StatisticsRecorder(selectorPrefix)

Method Description
record(statisticType, validationResult, value = 1) Increments statisticType and Total only when validationResult is falsy (item failed)
getTotal() Sum of all non-compliant hits
reset() Zero all counters
updateUI() Writes counts to elements whose id matches getStatLabelSelector(type)

Pair statisticType with config keys used in createStatisticsFormGroup(key) so bottom-panel labels reflect hide counts.


ComplianceRuleRecorder

Optional per-rule diagnostics when trackComplianceRules: true on the framework.

Method Description
record(configKey, ruleLabel, count = 1) Accumulate hides per filter + rule label
reset() Clear all recorded rules
getReport(resolveFilterLabel?) Sorted report: [{ filterKey, filterLabel, rules: [{ label, count }] }]

resolveFilterLabel maps internal keys to human-readable filter titles (framework passes Configuration Manager field titles).


Utilities (static)

Method Signature Notes
sleep (ms) => Promise Throttles deep attribute loads, paginator fetches, download queue
callEventHandler (handler, params?, defaultValue?) Invokes handler or returns default
callEventHandlerOrFail (name, handler, params?) Throws if handler missing
processEventHandlerQueue (handlers[], params?, defaultValue?) Runs all handlers in order
generateId `(prefix?) => number\ string`
toKebabCase (text) => string Lowercase, spaces → hyphens (tab ids, field keys)
trimAndKeepNonEmptyStrings (strings[]) => string[] Trim + drop empty
buildWholeWordMatchingRegex `(words[]) => RegExp\ null`
objectToJSON (object) => string Nested structure with arrays / objects / properties
objectFromJSON (json) => Object Inverse of objectToJSON
await Utilities.sleep(500)
const pattern = Utilities.buildWholeWordMatchingRegex(['foo', 'bar'])

Validator (static)

Method Signature Behaviour
isInRange (value, lower, upper) => boolean If both bounds > 0: inclusive range. If only lower > 0: value >= lower. If only upper > 0: value <= upper.
doesChildExist (item: JQuery, selector) => boolean item.find(selector).length > 0
isChildMissing (item, selector) => boolean Inverse of above
sanitize (text, rules) => string rules map: regex pattern → replacement string; then trim()
sanitizeTextNode (textNode: JQuery, rules) => Validator Mutates node text
sanitizeNodeOfSelector (selector, rules) => Validator Sanitizes node + document.title
regexMatches (text, rules) => boolean true if no rules or regex matches
validateTextDoesNotContain (text, rules) => boolean true if no rules or regex does not match
iFramesRemover () Injects iframe { display: none !important; } via GM_addStyle

Framework range filters and whitelist/blacklist paths use Validator internally. Custom comply callbacks often call isInRange and regexMatches.


Grants and load order

This module declares no Tampermonkey grants. Grant GM_addStyle, GM_download, GM_getValue, GM_setValue, etc. on the application script as needed.

@run-at document-end

Next in stack: View Layer