Ce script ne devrait pas être installé directement. C'est une librairie créée pour d'autres scripts. Elle doit être inclus avec la commande // @require https://update.greasyfork.org/scripts/416769/873075/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;
}
//============================== Library : WFTB_insertAfter ============//
function WFTB_insertAfter(WFTB_L_element, WFTB_L_target) {
WFTB_Log('WFTB_insertAfter', 4, 'Start');
WFTB_L_target.parentNode.insertBefore(WFTB_L_element, WFTB_L_target.nextSibling);
WFTB_Log('WFTB_insertAfter', 4, 'End');
}
//============================== Library : xpath ========================//
function WFTB_xpath(WFTB_L_query, WFTB_L_element) {
WFTB_Log('WFTB_xpath', 4, 'Start');
var WFTB_L_result = document.evaluate(WFTB_L_query, WFTB_L_element, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var WFTB_L_table = new Array();
var WFTB_L_cpt = 0;
for (WFTB_L_cpt = 0; WFTB_L_cpt < WFTB_L_result.snapshotLength; WFTB_L_cpt++) WFTB_L_table.push(WFTB_L_result.snapshotItem(WFTB_L_cpt));
WFTB_Log('WFTB_xpath', 4, 'End');
return WFTB_L_table;
}
function WFTB_single_xpath(WFTB_L_query, WFTB_L_element) {
WFTB_Log('WFTB_single_xpath', 4, 'Start');
var WFTB_L_elmFirstResult = document.evaluate(WFTB_L_query, WFTB_L_element, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
WFTB_Log('WFTB_single_xpath', 4, 'End');
return WFTB_L_elmFirstResult;
}
//=======================================================================//