WF Global Lib

Global library for all scripts that need it. Primary purpose, to serve Exolium's WazeForum scripts, but can be used by those who need it.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/439116/1012476/WF%20Global%20Lib.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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!)

// ==UserScript==
// @name            WF Global Lib
// @version         0.0.1.1
// @author          Exolium
// @copyright       2015-2022 Exolium
// @description     Global library for all scripts that need it. Primary purpose, to serve Exolium's WazeForum scripts, but can be used by those who need it.
// @description:fr  Bibliothèque globale pour tous les scripts qui en ont besoin. But premier, servir aux scripts WazeForum d'Exolium, mais peut être utiliser par ceux qui en ont besoin.
// @licence         GNU GPL v2
// @grant           GM_xmlhttpRequest
// ==/UserScript==


//================================ Library : xpath ===========================//

function WGL_xpath(WGL_L_query, WGL_L_element) {
 WGL_Log('WGL_xpath', 4, 'Start');

 var WGL_L_result = document.evaluate(WGL_L_query, WGL_L_element, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
 var WGL_L_table = new Array();
 var WGL_L_cpt = 0;

 for (WGL_L_cpt = 0; WGL_L_cpt < WGL_L_result.snapshotLength; WGL_L_cpt++) WGL_L_table.push(WGL_L_result.snapshotItem(WGL_L_cpt));
 WGL_Log('WGL_xpath', 4, 'End');
 return WGL_L_table;
}

function WGL_single_xpath(WGL_L_query, WGL_L_element) {
 WGL_Log('WGL_single_xpath', 4, 'Start');
 var WGL_L_elmFirstResult = document.evaluate(WGL_L_query, WGL_L_element, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
 WGL_Log('WGL_single_xpath', 4, 'End');
 return WGL_L_elmFirstResult;
}

//================================= Library : log ============================//
function WGL_Log(WGL_L_function, WGL_L_type, WGL_L_text) {
 WGL_L_text = 'Waze ' + GM_info.script.name + ' ' + GM_info.script.version + ' ' + WGL_L_function + ' : ' + WGL_L_text;

 switch(WGL_L_type) {
  case 1 : // error
   if(WGL_Log_level > 0) console.error(WGL_L_text);
   break;
  case 2 : // warn
   if(WGL_Log_level > 1) console.warn(WGL_L_text);
   break;
  case 3 : // min log
   if(WGL_Log_level > 2) console.info(WGL_L_text);
   break;
  case 4 : // Medium Log
   if(WGL_Log_level > 3) console.info(WGL_L_text);
   break;
  case 5 : // high detail Log
   if(WGL_Log_level > 4) console.info(WGL_L_text);
   break;
  default: // no log
   return;
 }
}
//============================================================================//