tampermonkey_utils

For Tampermonkey info

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/399614/788382/tampermonkey_utils.js

/*
Tampermonkey utils
*/

class TmUtils {
  static getClassName4Run() {
    const matches = GM_info.script.matches.map(s => s.replace(/\*$/, ''));
    const cfgFuncs = this.getUserScriptHeaders('classname');

    let funcName;
    const thisUrl = window.location.href;
    for (let len = matches.length, i = 0; i < len; i++) {
      if (thisUrl.includes(matches[i])) {
        funcName = cfgFuncs[i];
        break;
      }
    }
    console.log(`class name: ${funcName}`);
    return funcName;
  }

  static getUserScriptHeaders(name) {
    const reg = new RegExp(`(?<=\/\/ @${name})\\s+.*`, 'g');
    return (
      GM_info.script.header.match(reg).map(s => s.trim())
    );
  }
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址