tampermonkey_utils

For Tampermonkey info

ของเมื่อวันที่ 05-04-2020 ดู เวอร์ชันล่าสุด

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/399614/788382/tampermonkey_utils.js

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

/*
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())
    );
  }
}