89d7970
: Added DataStoreSerializer
methods serializePartial()
and deserializePartial()
for partial data exports and imports5d71770
: Added function purifyObj()
to remove an object's prototype chain (i.e. omit all inherited properties like toString
, __proto__
, etc.)24dad2b
: Fixed TS type for DataStoreSerializer.serialize()
905fea4
: Added function isDomLoaded()
to check if the DOM is queryable, regardless of @run-at
settingwithDecimals
to digitCount()
(true by default)roundFixed()
to round a floating-point number to the given amount of decimals. Can also round to the given power of 10.7e492cf
: Added probeElementStyle()
to probe the computed style of a temporary element, allowing to resolve CSS variables and default style values, etc.905fea4
: Added function onDomLoad()
to call a callback and/or resolve a Promise when the DOM is loaded, even retroactivelybitSetHas()
to check if a given value is present in a bitsetbf55335
: Replaced a bunch of generic Error
s with the new custom error class instancesbf55335
: Added custom error classes ChecksumMismatchError
, MigrationError
and PlatformError
, extending from the base class UUError
The base class has the additional property date
which is the time of the error creation157dacb
: Fixed example code in tsdoc comments of translation functionsdigitCount()
not counting decimals by defaulteb20132
: Added the type ListWithLength
to represent an array or object with a numeric length
, count
or size
property.eb20132
: Added autoPlural()
support for generic objects with a numeric length
, count
or size
property.c9b13d8
: Added signal: AbortSignal
and rejectOnAbort: boolean
params to pauseFor()
to allow for cutting the pause shortc66324b
: Support for words with -y
/-ies
extension in autoPlural()
c9b13d8
: Added getListLength()
function to resolve a value of the new ListWithLength
typec13e890
: autoPlural()
now defaults pluralType
to "auto"
and num
to 2 if pluralType
is invalid or num
resolves to NaN3f86215
: Fixed fetchAdvanced error "'abort' called on an object that does not implement interface AbortController"858c948
: Fix broken percent transform (tr.transforms.percent
)e3f1e6a
: Fixed Debouncer
TS types as to not break backwards compat5861bb4
: Fixed broken ambiguity of DataStore's migration function type69c4dd1
: Fixed wrong readme being included in JSR package and added @module
commentsf24f355
: Fixed missing return type signatures for JSR9abfc6b
: BREAKING - Reworked translation system:
tr()
, tr.setLanguage()
and tr.getLanguage()
tr.addLanguage()
to tr.addTranslations()
%n
-based argument insertion by default (re-enable explicitly with tr.addTransform(tr.transforms.percent)
).tr.for()
- translates a key for the specified language.tr.use()
- creates a translation function for the specified language for much easier usage.tr.hasKey()
- checks if a key exists in the given language.tr.setFallbackLanguage()
- sets the fallback language used when a key is not found in the given language.tr.getFallbackLanguage()
- returns the fallback language.tr.addTransform()
- adds a transform function to the translation system, allowing for custom argument insertion and much more.tr.deleteTransform()
- removes a transform function.${keyName}
) with tr.addTransform(tr.transforms.templateLiteral)
. This transform supports positional argument injection, as well as named arguments via an object with the same keys as in the template literal pattern. See the documentation for more information and a code example.TrKeys<T>
for extracting the keys of a translation object (both flat and nested).d0737dc
: BREAKING - Reworked debounce system:
rising
and falling
have been removed.immediate
and idle
with new behavior.immediate
(default & recommended) will trigger immediately, then queue all subsequent calls until the timeout has passed.idle
will trigger the last queued call only after there haven't been any subsequent calls for the specified timeout.Debouncer
class for more advanced control over debouncing, and with that the following changes:debounce()
function can still be called as usual (after replacing the edge type names with the new ones). Internally, it will instantiate a Debouncer
instance, which is available via the debouncer
property on the returned function.cd241b0
: Added additionalProps
parameter to openInNewTab()
to add or overwrite anchor element props (only if GM.openInTab()
is unavailable)d0737dc
: Moved documentation to separate file docs.md
to speed up README.md
load time.1a754db
: Fixed newlines being collapsed in TSDoc comments.d0737dc
: Fixed randRange()
with enhancedEntropy = true
only returning the first digit.e10d629
: Added function digitCount()
to calculate the amount of digits in the passed number949877a
: Added support for nested objects in translations (e.g. tr("foo.bar.baz")
)52d392a
: Added ValueGen
and StringGen
types with accompanying consumeGen()
and consumeStringGen()
functions to allow for super flexible typing and declaration of valuesbbce0e1
: Added overload to clamp()
without min
parameterca8b62e
: Made CJS bundle available on NPM too99abaab
: Made CJS bundle available on JSR390110e
: Throw an error when calling interceptEvent()
on window
or unsafeWindow
on FireMonkey instead of crashing the entire page1ecd63c
: Added support for the signal
property in fetchAdvanced()
3fe8b25
: Added overload to mapRange()
that only needs both max
values and assumes 0 for both min
valuesd7e8a31
: Added utility type Prettify
to make complex types more readable8ec2010
: Added randomCase
parameter to the function randomId()
(true by default)d9a36d5
: Added property migrateIds
to the constructor of DataStore
for easier ID migrationb2f757e
: Added enhancedEntropy
parameter to the function randRange()
(false by default)loadStoresData()
, resetStoresData()
and deleteStoresData()
for parallelized bulk operations on DataStore instancesb0bce9c
: Added DataStore method migrateId()
to be able to migrate to a new IDa8bca8f
: Added exports.types
in addition to just types
in package.jsona92000b
: Added exports
to package.json and corrected module
property54ee0ce
: Changed hexToRgb()
and rgbToHex()
to support #RGBA
and #RRGGBBAA
color codes (with an alpha channel).
Both functions now have an alpha
value immediately after blue
, which can be set to undefined
to restore the old behavior.54ee0ce
: Added parameter upperCase
(false by default) to lightenColor()
and darkenColor()
54ee0ce
: Consolidated behavior of lightenColor()
and darkenColor()
when using non-number values7e8e147
: - Added tr.forLang()
to get the translation for a specified language code
tr.getTranslations()
to return the translations object for the given or currently active languagea171b0d
: Fix color functions not being exported 🥴e00d4d9
: Fixed dev-only TypeScript shims being included in the final bundle3b8aa88
: Added color manipulation functions hexToRgb()
, rgbToHex()
, lightenColor()
and darkenColor()
7303aa2
: Added setInnerHtmlUnsafe()
for setting innerHTML unsanitized using a Trusted Types policy7303aa2
: Made addGlobalStyle()
use the new setInnerHtmlUnsafe()
to fix the error "This document requires 'TrustedHTML' assignment" on Chromium-based browsers7335c59
: Added Dialog class for easily creating customizable modal dialogsca50132
: Added NanoEmitter class for lightweight event emitter functionality in both OOP and FPd8f6852
: Fix package.json exportsfadebf0
: Removed the function insertAfter()
because the DOM API already has the method insertAdjacentElement()
that has the same functionality and even four positions to pick from.
To get the same behavior as insertAfter(refElem, newElem)
, you can use refElem.insertAdjacentElement("afterend", newElem)
ca6ff58
: Added option checkInterval
to SelectorObserver to check on interval instead of on mutation1e2015c
: Added DataStoreSerializer
class for centralized and much easier and safer de-/serialization of any number of DataStore instances5190f0b
: SelectorObserver's addListener()
now returns an unsubscribe function to more easily remove a listenere1d467c
: Added function computeHash()
to calculate the hash / checksum of a string948ac89
: DataStore: made runMigrations
, encodeData
and decodeData
public and added encodingEnabled
methodd7cdac0
: Made randomId()
default to using Math.random() and added the parameter enhancedEntropy
to revert back to the much slower but also much more entropic implementation287b006
: Added ability to change DataStore storage engine from default "GM" to "localStorage" and "sessionStorage"fa09004
: Made openInNewTab()
use GM.openInTab
by default and fall back to the old behavior.
Also added background
param to specify if the tab should get focus when opened.SelectorObserver
instancesa11ed77
: Added parameter to switch debounce()
to trigger on the rising edge, instead of just the falling edge (see docs)08248c1
: Fixed terminology in JSDoc comments of the DataStore
classe921593
: Renamed ConfigManager
to DataStore
to make its implied purpose as a generic JSON database more clear.
defaultConfig
is now called defaultData
deleteConfig()
is now called deleteData()
_uucfg
for backwards compatibilityda679c6
: Added function getSiblingsFrame()
that returns a frame of an element's siblings, with a given alignment and size0c716a6
: Lowered the Error.stackTraceLimit
by a multiple of 10 to preserve memory2b885c3
: ConfigManager.loadData()
now returns a copy of the datac980ff3
: compress()
now uses the same value "string" (unlike previously "base64") for the outputType parameter like decompress()
ca1b596
: Added encodeData()
and decodeData()
to the ConfigManager options to allow for easy data compression0462e35
: Fixed TS types for overload of SelectorObserver constructor47639f0
: Added SelectorObserver options disableOnNoListeners
and enableOnAddListener
4a58caa
: addGlobalStyle
now returns the created style elementfetchAdvanced
is now a drop-in replacement and timeout can now optionally be disabled17a6ad5
: randomizeArray
now returns a copy if an empty array is passed as well885323d
: Added function observeElementProp
to allow observing element property changesdae5450
: Removed amplifyMedia
function due to massive inconsistencies in sound quality168c2aa
: Added functions compress
and decompress
to compress and decompress strings using gzip or deflate49bc85e
: Added utility types NonEmptyString
and LooseUnion
2ae665d
: fixed wrong TS type for SelectorObserver options in constructor1859022: onSelector()
has been turned into the SelectorObserver
class to reduce the performance impact on larger sites:
debounce()
function, but is disabled by default)The SelectorObserver.addListener()
method is backwards compatible with the old onSelector()
function, so you can just add the class instance in front (for full backwards compat use document.body
for the baseElement
parameter of the constructor), then change the old function's name and it should work as before.
For more info and examples, please view the SelectorObserver documentation
0db73b5
: Removed the limiter (DynamicsCompressorNode) from amplifyMedia()
for clear and undistorted audio.Notable changes:
source
has been renamed to sourceNode
to fit the naming of the gainNode
propertyenabled
has been added to check if the amplification is enabled or notThe parameter initialMultiplier
has been renamed to initialGain
to reduce confusion (it is not a multiplier strictly speaking)
736784f
: Added function randomId()
to randomly generate cryptographically strong hexadecimal IDs
563e515
: Added utility type NonEmptyArray
for typing an array with at least 1 item
a123da6
: Added @linkcode
references to the JSDoc in-IDE documentation63af1a7
: Change default limiter options to be more balancedb53a946
: Added compression to amplifyMedia()
to prevent audio clipping and distortion and modified return type accordingly:
amplify()
to setGain()
and getAmpLevel()
to getGain()
enable()
, disable()
, setLimiterOptions()
and limiterNode
enable()
must now be called manually after initializing84b37f1
: Added utility type Stringifiable to describe a string or any value that can be converted to one142c5e2
: Added function insertValues() to insert values into a string with placeholders16ce257
: Added lightweight translation systemad17374
: Add support for OpenUserJS049aeb0
: Export ConfigMigrationsDict for easier use with TypeScript4799a9f
: Fix TS error in ConfigManager migration functionsdb5cded
: Added isScrollable()
to check whether an element has a horizontal or vertical scroll bar9e26464
: Replaced most occurrences of HTMLElement
in the docs with Element
for better compatibilitya500a98
: Added ConfigManager to manage persistent user configurations including data versioning and migration6d0a700
: Event interceptor can now be toggled at runtime (#16)d038b21
: Global (IIFE) build now comes with a headerf97dae6
: change bundling process18d4a10
: make npm bundle smalleraa8efbd
: fix documentation54e7905
: Features:
amplifyMedia()
to boost the volume of a MediaElement past its default maximumMutationObserver.observe()
options to be passed to initOnSelector()
Fixes:
onSelector()
not triggering correctly85ec87b
: fix missing export for array functions231a79c
: Refactored code and documentation and added new functions:
mapRange()
to map a number from one range to the same spot in another rangerandRange()
to generate a random number between a min and max boundaryrandomItem()
to return a random item from an arrayrandomItemIndex()
to return a tuple of a random item and its index from an arraytakeRandomItem()
to return a random item from an array and mutate it to remove the itemrandomizeArray()
to return a copy of the array with its items in a random order7edf837
: decrease npm bundle size07ec443
: add getSelectorMap()
to return all currently registered selectors0cf2254
: add onSelector()
to call a listener once a selector is found in the DOMbb60db0
: minor fixes9206f6e
: Initial release - Features:
onSelector()
to call a listener once a selector is found in the DOMautoPlural()
to automatically pluralize a stringclamp()
to clamp a number between a min and max valuepauseFor()
to pause the execution of a function for a given amount of timedebounce()
to call a function only once, after a given amount of timegetUnsafeWindow()
to get the unsafeWindow object or fall back to the regular window objectinsertAfter()
to insert an element as a sibling after another elementaddParent()
to add a parent element around another elementaddGlobalStyle()
to add a global style to the pagepreloadImages()
to preload images into the browser cache for faster loading later onfetchAdvanced()
as a wrapper around the fetch API with a timeout optionopenInNewTab()
to open a link in a new tabinterceptEvent()
to conditionally intercept events registered by addEventListener()
on any given EventTarget objectinterceptWindowEvent()
to conditionally intercept events registered by addEventListener()
on the window object