WF ToolBox Lib Alpha

When prema is present to offer his version for beta + classic editor and add the profile editor waze

Tính đến 25-11-2020. Xem phiên bản mới nhất.

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/416769/873061/WF%20ToolBox%20Lib%20Alpha.js

// ==UserScript==
// @name            WF ToolBox Lib Alpha
// @namespace       WFTB_ns
// @version         0.0.1.6
// @description:en  When prema is present to offer his version for beta + classic editor and add the profile editor waze
// @description:fr  Quand un perma est présent proposer sa version pour l'éditeur beta + classique et ajout du editor profile waze
// @author          exolium
// @copyright       2015-2020 exolium
// @licence         GNU GPL v2
// @grant           GM_xmlhttpRequest
// @description When prema is present to offer his version for beta + classic editor and add the profile editor waze
// ==/UserScript==

//============================== Options ================================//
var WFTB_lang_en = 0;
var WFTB_lang_fr = 1;

var WFTB_label_setting_manager = ['Settings Manager', 'Gestionnaire de Paramètres'];
var WFTB_label_close = ['Close', 'Fermer'];
var WFTB_Log_level = 5; // 0 = no log / 1 = error / 2 = warn / 3 = min log / 4 = Medium Log / 5 = high detail Log
var WFTB_targetblank = true;
var WFTB_use_layer = true;
var WFTB_button_beta = 'Beta';
var WFTB_button_prod = 'Prod';
var WFTB_button_editorprofil = 'Editor Profil A';
var WFTB_lang = WFTB_lang_en;

//============================== Var ====================================//
var WFTB_beta_editor_verify = false;
var WFTB_beta_editor = false;
var WFTB_profil = Array();
var WFTB_Settings = {};

//============================== URL ====================================//
var WFTB_URL_protocol = window.location.protocol + '//';
var WFTB_URL_Base = window.location.hostname;
var WFTB_URL_usergroups = WFTB_URL_protocol + WFTB_URL_Base + '/forum/ucp.php?i=167';
var WFTB_URL_UserProfil_URI = '/user/editor/';

//============================== Recherche ==============================//
var WFTB_search_base_url = '//a[contains(@href,\'editor-beta.waze.com\') or (@href,\'beta.waze.com\') or contains(@href,\'www.waze.com\')][contains(@href,\'editor\')]';
var WFTB_search_perma_layer = 'layers=w+';
var WFTB_search_usergroups_memberships = '//*[@id="ucp"]/div[1]/div/ul[2]';
var WFTB_search_usergroups_memberships_groups = ['//*[@id="ucp"]/div[1]/div/ul[2]/li','//*[@id="ucp"]/div[1]/div/ul[4]/li'];
var WFTB_search_usergroups_name = '';
var WFTB_search_usergroups_if_leadersheep = '//*[@id="ucp"]/div[1]/div/ul[1]/li/dl/dt';
var WFTB_search_Lang_Selector = '/html/body/div[3]/div[1]/div[6]/div';
var WFTB_search_linklist = '//*[@id="wrap"]/div[2]/div/ul[2]/li[2]';

//============================== Library : log ==========================//
function WFTB_Log(WFTB_L_function, WFTB_L_type, WFTB_L_text) {
 WFTB_L_text = 'Waze ' + GM_info.script.name
        + ' ' + GM_info.script.version
        + ' ' + WFTB_L_function
        + ' : ' + WFTB_L_text;

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

//============================== WFTB_updatePerma ======================//
function WFTB_checkupdate() {
 WFTB_Log('WFTB_checkupdate', 4, 'End');

 WFTB_Log('WFTB_checkupdate', 5, 'WFTB_Settings.version=' + WFTB_Settings.version);
 WFTB_Log('WFTB_checkupdate', 5, 'GM_info.script.version=' + GM_info.script.version);

 if(WFTB_Settings.version != GM_info.script.version) {
  WFTB_Settings.version = GM_info.script.version;
  localStorage.WFTB_data = JSON.stringify(WFTB_Settings);
  WFTB_Log('WFTB_checkupdate', 5, JSON.stringify(WFTB_Settings));
 }

 if(WFTB_Settings.app_name != GM_info.script.name) {
  WFTB_Settings.app_name = GM_info.script.name;
  localStorage.WFTB_data = JSON.stringify(WFTB_Settings);
  WFTB_Log('WFTB_checkupdate', 5, JSON.stringify(WFTB_Settings));
 }

 WFTB_Log('WFTB_checkupdate', 4, 'End');
}
//============================== Library : Version type ========================//
function WFTB_version(){
 var return_version;
 var WFTB_version_prod = new RegExp("^(?:[0-9]{1,10}\.){1}[0-9]{1,10}$");
 var WFTB_version_beta = new RegExp("^(?:[0-9]{1,10}\.){2}[0-9]{1,10}$");
 var WFTB_version_alpha = new RegExp("^(?:[0-9]{1,10}\.){3}[0-9]{1,10}$");

 if (WFTB_version_alpha.test(WFTB_Settings.version)) {
  WFTB_Log_level = 5 
  return 'alpha';
 } else if (WFTB_version_beta.test(WFTB_Settings.version)) {
  WFTB_Log_level = 3
  return 'beta';
 } else if (WFTB_version_prod.test(WFTB_Settings.version)) {
  WFTB_Log_level = 1
  return 'prod';
 } else return false;
}

//=======================================================================//