Greasy Fork is available in English.

tampermonkey_utils

For Tampermonkey info

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/399614/788382/tampermonkey_utils.js

  1. /*
  2. Tampermonkey utils
  3. */
  4.  
  5. class TmUtils {
  6. static getClassName4Run() {
  7. const matches = GM_info.script.matches.map(s => s.replace(/\*$/, ''));
  8. const cfgFuncs = this.getUserScriptHeaders('classname');
  9.  
  10. let funcName;
  11. const thisUrl = window.location.href;
  12. for (let len = matches.length, i = 0; i < len; i++) {
  13. if (thisUrl.includes(matches[i])) {
  14. funcName = cfgFuncs[i];
  15. break;
  16. }
  17. }
  18. console.log(`class name: ${funcName}`);
  19. return funcName;
  20. }
  21.  
  22. static getUserScriptHeaders(name) {
  23. const reg = new RegExp(`(?<=\/\/ @${name})\\s+.*`, 'g');
  24. return (
  25. GM_info.script.header.match(reg).map(s => s.trim())
  26. );
  27. }
  28. }