Last active
September 3, 2017 09:13
-
-
Save serge-kilimoff/891e9f668a483f17ccea860d0677fc5d to your computer and use it in GitHub Desktop.
Extension chrome ou greasemonkey pour ajouter des raccourcis vers certaines fenêtres dans grepolis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name grepolis-manager-ui | |
// @namespace http://grepolis.com/ | |
// @version 1.0 | |
// @description Ajoute des liens pour l'ouverture des menus comme avec l'option premium de manager | |
// @author Serge Kilimoff-Goriatchkine | |
// @match https://*.grepolis.com/game/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Configuration des liens de raccourcis | |
// `label` (qui peut être du html) correspond à ce qui est affiché à l'écran | |
// `fn` correspond à la fonction appelée lors du clique sur le lien | |
// Les fonctions ont été récupéré depuis https://wiki.en.grepolis.com/wiki/The_Game_Interface#Quick_Bar | |
let configLinks = { | |
senate: { | |
label: 'Sénat', | |
fn: () => MainWindowFactory.openMainWindow(), | |
}, | |
cave: { | |
label: 'Grotte', | |
fn: () => HideWindowFactory.openHideWindow(), | |
}, | |
warehouse: { | |
label: 'Entrepôt', | |
fn: () => BuildingWindowFactory.open('storage'), | |
}, | |
farm: { | |
label: 'Ferme', | |
fn: () => FarmWindowFactory.openFarmWindow(), | |
}, | |
timberCamp: { | |
label: 'Scierie', | |
fn: () => LumberWindowFactory.openLumberWindow(), | |
}, | |
quarry: { | |
label: 'Carrière', | |
fn: () => StonerWindowFactory.openStonerWindow(), | |
}, | |
silverMine: { | |
label: 'Mine d\'argent', | |
fn: () => IronerWindowFactory.openIronerWindow(), | |
}, | |
marketPlace: { | |
label: 'Marché', | |
fn: () => MarketWindowFactory.openMarketWindow(), | |
}, | |
harbor: { | |
label: 'Port', | |
fn: () => DocksWindowFactory.openDocksWindow(), | |
}, | |
barracks: { | |
label: 'Caserne', | |
fn: () => BarracksWindowFactory.openBarracksWindow(), | |
}, | |
cityWall: { | |
label: 'Rempart', | |
fn: () => BuildingWindowFactory.open('wall'), | |
}, | |
academy: { | |
label: 'Académie', | |
fn: () => AcademyWindowFactory.openAcademyWindow(), | |
}, | |
temple: { | |
label: 'Temple', | |
fn: () => TempleWindowFactory.openTempleWindow(), | |
}, | |
agoraDefence: { | |
label: 'Agora (défence)', | |
fn: () => PlaceWindowFactory.openPlaceWindow('index', open), | |
}, | |
troopsOutside: { | |
label: 'Troupes en dehors', | |
fn: () => PlaceWindowFactory.openPlaceWindow('units_beyond', open), | |
}, | |
simulator: { | |
label: 'Simulateur', | |
fn: () => PlaceWindowFactory.openPlaceWindow('simulator', open), | |
}, | |
culture: { | |
label: 'Culture', | |
fn: () => PlaceWindowFactory.openPlaceWindow('culture', open), | |
}, | |
}; | |
// La configuration générale de la barre de menu | |
// Elle est divisée en deux. Chaque élément de positionnement | |
// doit contenir un pointeur vers une config présente dans configLinks. | |
let uiBarConfig = { | |
left: [ | |
configLinks.senate, | |
configLinks.academy, | |
configLinks.marketPlace, | |
configLinks.culture, | |
], | |
right: [ | |
configLinks.simulator, | |
configLinks.cave, | |
configLinks.harbor, | |
configLinks.barracks, | |
], | |
}; | |
uiBarConfig.right.reverse(); | |
// On vérifie si la barre de raccourcis existent et si elle ne contient pas déjà des choses | |
let uiBar = $('.ui_quickbar'); | |
if (!uiBar.length) return; | |
if (uiBar.has('*').length) return; | |
// On place les raccourcis | |
uiBarConfig.left.forEach(cfg => appendToUiBar(uiBar, 'left', cfg)); | |
uiBarConfig.right.forEach(cfg => appendToUiBar(uiBar, 'right', cfg)); | |
// Place les raccourcis sur la barre, selon une position 'left' ou 'right' | |
function appendToUiBar(uiBar, position, cfg) { | |
let link = $('<a href="#"></a>'); | |
link.html(cfg.label); | |
link.css({ | |
'float': position, | |
'margin': '0 3em', | |
'color': 'white', | |
'line-height': '1.6', | |
}); | |
link.click(cfg.fn); | |
uiBar.append(link); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pour ajouter dans chrome, aller dans le menu des extensions de chrome, puis glisser-déposer le fichier.
Pour modifier le fichier (il a été prévu pour un écran HD) :
Ou installer l'extension tempermonkey (https://chrome.google.com/extensions/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo), permettant de créer des scripts js pour des sites.