UserUtils

Various utilities for userscripts - register listeners for when CSS selectors exist, intercept events, manage persistent & synchronous JSON databases, modify the DOM more easily, useful math and array functions and more

To są wersje tego skryptu, gdzie kod został zaktualizowany. Pokaż wszystkie wersje.

  • v8.3.2 11-11-2024
    • Made CJS bundle available on JSR
  • v8.3.1 11-11-2024
    • Throw an error when calling interceptEvent() on window or unsafeWindow on FireMonkey instead of crashing the entire page
  • v8.3.0 08-11-2024
    • Added support for the signal property in fetchAdvanced()
  • v8.2.0 08-11-2024
    • Added overload to mapRange() that only needs both max values and assumes 0 for both min values
    • Added utility type Prettify to make complex types more readable
    • Added randomCase parameter to the function randomId() (true by default)
    • Added property migrateIds to the constructor of DataStore for easier ID migration
    • Added enhancedEntropy parameter to the function randRange() (false by default)
  • v8.1.0 24-10-2024
    • Added new DataStoreSerializer methods loadStoresData(), resetStoresData() and deleteStoresData() for parallelized bulk operations on DataStore instances
    • Added DataStore method migrateId() to be able to migrate to a new ID
  • v8.0.2 16-09-2024
    • Added exports.types in addition to just types in package.json
  • v8.0.1 16-09-2024
    • Added exports to package.json and corrected module property
  • v8.0.0 04-09-2024
    • 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.
    • Added parameter upperCase (false by default) to lightenColor() and darkenColor()
    • Consolidated behavior of lightenColor() and darkenColor() when using non-number values
  • v7.3.0 03-09-2024
    • Added tr.forLang() to get the translation for a specified language code
    • Added tr.getTranslations() to return the translations object for the given or currently active language
  • v7.2.2 29-08-2024
    • Fixed color functions not being exported
  • v7.2.1 28-08-2024
    • Removed dev-only TypeScript shims which were accidentally included in the final bundle
  • v7.2.0 28-08-2024
    • Added color manipulation functions hexToRgb(), rgbToHex(), lightenColor() and darkenColor()
    • Added setInnerHtmlUnsafe() for setting innerHTML unsanitized using a Trusted Types policy
    • Made addGlobalStyle() use the new setInnerHtmlUnsafe() to fix the error "This document requires 'TrustedHTML' assignment" on Chromium-based browsers
  • v7.1.0 08-08-2024
    • Added Dialog class for easily creating customizable modal dialogs
    • Added NanoEmitter class for lightweight event emitter functionality in both object-oriented and functional programming styles
  • v7.0.0 04-08-2024
    • 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)
    • Added option checkInterval to SelectorObserver to check on interval instead of on mutation
    • Added DataStoreSerializer class for centralized and much easier and safer de-/serialization of any number of DataStore instances
    • SelectorObserver's addListener() now returns an unsubscribe function to more easily remove a listener
    • Added function computeHash() to calculate the hash / checksum of a string
    • DataStore: made runMigrations, encodeData and decodeData public and added encodingEnabled method
    • Made randomId() default to using Math.random() and added the parameter enhancedEntropy to revert back to the much slower but also much more entropic implementation
    • Added ability to change DataStore storage engine from default "GM" to "localStorage" and "sessionStorage"
  • v6.3.0 06-04-2024
    • 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.
  • v6.2.0 02-04-2024
    • Add property to change the debounce edge in SelectorObserver instances
  • v6.1.0 02-04-2024
    • Added parameter to switch debounce() to trigger on the rising edge, instead of just the falling edge (see docs)
  • v6.0.1 24-03-2024
    • Fixed terminology in JSDoc comments of the DataStore class
  • v6.0.0 23-03-2024
    • Renamed ConfigManager to DataStore to make its implied purpose as a generic JSON database more clear.
      • the constructor property defaultConfig is now called defaultData
      • deleteConfig() is now called deleteData()
      • the internal GM storage keys will still have the prefix _uucfg for backwards compatibility
    • Added function getSiblingsFrame() that returns a frame of an element's siblings, with a given alignment and size
    • Lowered the Error.stackTraceLimit by a multiple of 10 to preserve memory
  • v5.0.1 28-02-2024
    • ConfigManager.loadData() now returns a copy of the data instead of a reference
  • v5.0.0 20-02-2024
    • compress() now uses the same value "string" (unlike previously "base64") for the outputType parameter like decompress()
    • Added encodeData() and decodeData() to the ConfigManager options to allow for easy data compression
  • v4.2.1 16-02-2024
    • Fixed TS types for overload of SelectorObserver constructor
  • v4.2.0 16-02-2024
    • Added SelectorObserver options disableOnNoListeners and enableOnAddListener
    • addGlobalStyle now returns the created style element
    • fetchAdvanced is now a drop-in replacement and timeout can now optionally be disabled
  • v4.1.0 05-01-2024

    - Added function `observeElementProp` to watch for a property of an element to change that isn't observable with MutationObserver

  • v4.0.0 21-11-2023
    • Removed amplifyMedia function due to massive inconsistencies in sound quality
    • Added functions compress and decompress to compress and decompress strings using gzip or deflate
    • Added TS utility types NonEmptyString and LooseUnion
    • Fixed wrong TS type for SelectorObserver options in constructor
  • v3.0.0 12-11-2023

    - `onSelector()` has been turned into the `SelectorObserver` class to reduce the performance impact on larger sites ([see migration info here](https://github.com/Sv443-Network/UserUtils/blob/main/CHANGELOG.md#300))
    - Removed the limiter from `amplifyMedia()` for clear and undistorted audio and renamed properties ([see migration info here](https://github.com/Sv443-Network/UserUtils/blob/main/CHANGELOG.md#300))
    - Added function `randomId()` to randomly generate cryptographically strong hexadecimal IDs
    - Added utility type `NonEmptyArray` for typing an array with at least 1 item

  • v2.0.1 04-10-2023

    Changed default limiter options to be more balanced

  • v2.0.0 01-10-2023

    Added compression to amplifyMedia() to prevent audio clipping and distortion and modified return type accordingly:

    • Renamed: amplify() to setGain() and getAmpLevel() to getGain()
    • Added properties: enable(), disable(), setLimiterOptions() and limiterNode
    • Other changes: Amplification is no longer enabled automatically, enable() must now be called manually after initializing
  • v1.2.0 21-09-2023
    • Added function insertValues() to insert values into a string with placeholders
    • Added lightweight translation system using tr()
  • v1.1.3 19-09-2023

    Added UserLibrary header

  • v1.1.2 16-09-2023

    Exported ConfigMigrationsDict for easier use with TypeScript

  • v1.1.1 14-09-2023

    Fixed TypeScript error in ConfigManager migrations

  • v1.1.0 12-09-2023

    Added isScrollable() to check whether an element has a horizontal or vertical scroll bar

  • v1.0.0 07-09-2023

    Major Changes

    • a500a98: Added ConfigManager to manage persistent user configurations including data versioning and migration

    Patch Changes

    • 6d0a700: Event interceptor can now be toggled at runtime (#16)
    • d038b21: Global (IIFE) build now comes with a header
  • v0.5.3 04-09-2023

    code is no longer minified and now has a userscript header

  • v0.0.1.20230812204639 12-08-2023