NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @namespace https://openuserjs.org/users/mandalorien // @name Sethi - Functions // @author mandalorien // @version 0.1.1 // @description liste des différentes fonctions utilisés // @copyright 2020, mandalorien (https://openuserjs.org/users/mandalorien) // @license GPL-2.0-only // @require https://code.jquery.com/jquery-3.4.1.min.js // @updateURL https://openuserjs.org/meta/mandalorien/Sethi_-_Functions.meta.js // @downloadURL https://openuserjs.org/install/mandalorien/Sethi_-_Functions.user.js // @grant GM_xmlhttpRequest // @grant GM_addStyle // @run-at document-end // ==/UserScript== // ==OpenUser JS== // @author mandalorien // ==OpenUser JS== /**** * PARAM : param is text focus get url parameters * ****/ function $_GET(param) { var vars = {}; window.location.href.replace( location.hash, '' ).replace( /[?&]+([^=&]+)=?([^&]*)?/gi, // regexp function( m, key, value ) { // callback vars[key] = value !== undefined ? value : ''; } ); if ( param ) { return vars[param] ? vars[param] : null; } return vars; } /**** * PARAM : Data is array object container data send * ****/ function sendData(Data){ let _R = "url to send data"; $.ajax({ method: "POST", url: _R, data: Data, dataType:'json' }) .done(function(_RESULT){ }); } function findCoord(htmlb,text,iindex){ const regex = /\[[^[\]]*\]/gm; let m; let _array = []; while ((m = regex.exec(text)) !== null) { // This is necessary to avoid infinite loops with zero-width matches if (m.index === regex.lastIndex) { regex.lastIndex++; } let coord = m[0]; _array.push(coord); } /* pour savoir de ou a ou */ var _Moon = 0; if($($(htmlb).find('figure')[1]).length > 0){ if($($(htmlb).find('figure')[1]).hasClass('moon')){ _Moon = 1; } }else{ _Moon = 0; } let position = _array[iindex].split(':'); return { galaxy:parseFloat(position[0].substr(1,position[0].length)), system:parseFloat(position[1]), planet:parseFloat(position[2].substr(0,position[0].length)), isMoon:_Moon }; } function findPlayerName(text){ const regex = /\((.*)\)/; let m; if ((m = regex.exec(text)) !== null) { // The result can be accessed through the `m`-variable. let playerName = m[1]; return playerName; } } function selectShips(fleetDispatcher,shipID, amount) { fleetDispatcher.shipsOnPlanet.forEach(ship => { if(ship.id == shipID) { if(amount > ship.number) { amount = ship.number; document.querySelector(`.technology[data-technology="${ship.id}"]`).classList.add('ogl-notEnough'); } fleetDispatcher.selectShip(parseInt(shipID), parseInt(amount)); fleetDispatcher.refresh(); if(document.querySelector('#continueToFleet2')) document.querySelector('#continueToFleet2').focus(); } }); return amount; }