Common.Utils

Classes for your scripts

此脚本不应被直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.org/scripts/389765/1090053/CommonUtils.js

脚本作者
Anton Shevchuk
版本
0.0.7
创建日期
2019-09-04
最近更新
2022-09-05
许可证
MIT

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() );

Links

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