tampermonkey_utils

For Tampermonkey info

Stan na 05-04-2020. Zobacz najnowsza wersja.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/399614/788382/tampermonkey_utils.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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