Skip to content
UI plugin

CommunityScriptsUILibrary

CommunityScripts UI helper library

feederbox826
Not reviewed yet

No reviewer has approved this plugin yet. Read the source before installing, or review it for the community.

sha256 72978e1e43569b85cab182e6fa573aeb650e8c5c9d2167a233ed6cca0ab95ac5

Last updated

Nov 27, 2024
First created
Version
1.0.0-512fbb8
Package id
CommunityScriptsUILibrary
Commits
3
Repo stars
284

README

CommunityScripts UI Plugin library

This is a set of slimmed down functions from StashUserscriptLibrary, targeting CommunityScripts originally introduced in #319

functions

All the following functions are exposed under window.csLib and csLib

callGQL

/**
   * This is a wrapped GraphQL (GQL) query caller
   * @param {...Object} reqData
   * @param {Object} reqData.query - GraphQL query
   * @param {Object}= reqData.variables - GraphQL variables
   * @returns {Object} - GQL response data with the `data` wrapper removed
   * 
   * @example
   *   // fetch the count of organized scenes
   *   const filter = { organized: true };
   *   const query = `query findScenes($filter: SceneFilter) { findScenes(filter: $filter) { count } }`;
   *   const variables = { filter };
   *   const response = await callGQL({ query, variables });
   *   // response = { findScenes: { count: 3 } }
   */

getConfiguration

/**
   * Get configuration of a plugin from the server via GraphQL
   * @param {string} pluginId - The ID of the plugin as it is registered in the server
   * @param {*}= fallback - Fallback value if the configuration is not found. Defaults to an empty object
   * @returns {Object} - The configuration object of the plugin as it is stored in the server
   * 
   * @example
   *    // set default config
   *    const defaultConfig = { enabled: true, theme: 'light' };
   *    // fetch config from the server
   *    const config = await getConfiguration('CommunityScriptsUIPlugin', defaultConfig);
   *    // config = { theme: 'dark' }
   *    // merge fetched with default config
   *    const pluginConfig = {
   *      ...defaultConfig
   *      ...config
   *    };
   *    // pluginConfig = { enabled: true, theme: 'dark' }
   * }
   */

setConfiguration

/**
   * Set configuration of a plugin in the server via GraphQL
   * @param {string} pluginId - The ID of the plugin as it is registered in the server
   * @param {*} values - The configuration object with the values you want to save in the server
   * @returns {Object} - The configuration object of the plugin as it is stored in the server after update
   *
   * @example
   *    // fetch config from the server
   *    const config = await getConfiguration('CommunityScriptsUIPlugin', defaultConfig);
   *    // config = { theme: 'dark' }
   *    // update the config based on user input
   *    // config = { theme: 'light' }
   *    // save config in the server
   *    await setConfiguration('CommunityScriptsUIPlugin', config);
   * }
   */

waitForElement

  /**
   * Waits for an element to be available in the DOM and runs the callback function once it is
   * @param {string} selector - The CSS selector of the element to wait for
   * @param {function} callback - The function to be called once the element is available (with the element as an argument)
   * @returns 
   * 
   * @example
   *   // wait for the element with the class 'my-element' to be available
   *   // and change its color to red
   *   function myCallback(el) {
   *     el.style.color = 'red';
   *    };
   *    waitForElement('.my-element', myCallback);
   */

pathElementListener

Contributors

More from stashapp/CommunityScripts

  • Scene Page Remember StatesUses local storage to remember the state of the scene page detail panel nav bar and activate it on page load. Remembers collapse state of the divider.
  • Marker Delete ButtonAdds a delete button to entries on the Markers page and on the Scene page.
  • Python Tools InstallerDownload stashapp-tools for DockerEnv
  • Scene Cover CropperCrop Scene Cover Images
  • RandomButtonAdds a button to quickly jump to a random scene, image, performer, studio, group, tag, or gallery, both on overview and internal entity pages.
  • Comic Info ExtractorExtract the metadata from cbz with the Comicrack standard (ComicInfo.xml)
  • Video Chapter MarkersCreate markers from chapter information embedded in video files
  • Timestamp TradeSync Markers with timestamp.trade, a new database for sharing markers.

See all 90 from this source →