Common.Utils

Classes for your scripts

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/389765-common-utils/code/CommonUtils.js?version=822474

Author
Anton Shevchuk
Ratings
0 0 0
Version
0.0.4
Created
2019-09-04
Updated
2020-07-02
License
MIT
Applies to
All sites

Common Utils

Require Script

// @require https://greasyfork.org/scripts/389765-common-utils/code/CommonUtils.js?version=XXX

See last available version on the GreasyFork homepage

Container

Cache

let CacheInstance = new SimpleCache();
let result = null;
if (CacheInstance.has('key')) {
  result = CacheInstance.get('key');
} else {
  result = await $.ajax('url');
  CacheInstance.set('key', result);
}

Settings

Load settings

let SettingsInstance = new Settings('script name', {'default':'settings'});

Save settings

With jQuery:

$(window).on('beforeunload', () => SettingsInstance.save() );

Tools

Copy to clipboard

Tools.copyToClipboard('some text')

Links

Author homepage: http://anton.shevchuk.name/
Script homepage: https://github.com/AntonShevchuk/common.utils
GreasyFork: https://greasyfork.org/uk/scripts/389765-common-utils