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

这些是代码更新过的版本。 显示所有版本

  • v8.3.0 2024-11-08
    • Added support for the signal property in fetchAdvanced()
  • v8.2.0 2024-11-08
    • 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 2024-10-24
    • 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 2024-09-16
    • Added exports.types in addition to just types in package.json
  • v8.0.1 2024-09-16
    • Added exports to package.json and corrected module property
  • v8.0.0 2024-09-04
    • 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 2024-09-03
    • 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 2024-08-29
    • Fixed color functions not being exported
  • v7.2.1 2024-08-28
    • Removed dev-only TypeScript shims which were accidentally included in the final bundle
  • v7.2.0 2024-08-28
    • 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 2024-08-08
    • 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 2024-08-04
    • 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 2024-04-06
    • 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 2024-04-02
    • Add property to change the debounce edge in SelectorObserver instances
  • v6.1.0 2024-04-02
    • Added parameter to switch debounce() to trigger on the rising edge, instead of just the falling edge (see docs)
  • v6.0.1 2024-03-24
    • Fixed terminology in JSDoc comments of the DataStore class
  • v6.0.0 2024-03-23
    • 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 2024-02-28
    • ConfigManager.loadData() now returns a copy of the data instead of a reference
  • v5.0.0 2024-02-20
    • 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 2024-02-16
    • Fixed TS types for overload of SelectorObserver constructor
  • v4.2.0 2024-02-16
    • 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 2024-01-05

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

  • v4.0.0 2023-11-21
    • 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 2023-11-12

    - `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 2023-10-04

    Changed default limiter options to be more balanced

  • v2.0.0 2023-10-01

    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 2023-09-21
    • Added function insertValues() to insert values into a string with placeholders
    • Added lightweight translation system using tr()
  • v1.1.3 2023-09-19

    Added UserLibrary header

  • v1.1.2 2023-09-16

    Exported ConfigMigrationsDict for easier use with TypeScript

  • v1.1.1 2023-09-14

    Fixed TypeScript error in ConfigManager migrations

  • v1.1.0 2023-09-12

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

  • v1.0.0 2023-09-07

    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 2023-09-04

    code is no longer minified and now has a userscript header

  • v0.0.1.20230812204639 2023-08-12