DC - FullWall TESTER

Full Wall Tester. Idée et code de base d'Odul, voir ici: https://greasyfork.org/en/scripts/1555-fullwall/code

  1. // ==UserScript==
  2. // @name DC - FullWall TESTER
  3. // @namespace DreadCast
  4. // @include http://www.dreadcast.net/Main
  5. // @grant none
  6. // @author Ianouf
  7. // @date 14/03/2015
  8. // @version 1.1
  9. // @description Full Wall Tester. Idée et code de base d'Odul, voir ici: https://greasyfork.org/en/scripts/1555-fullwall/code
  10. // @compat Firefox, Chrome
  11. // @require http://code.jquery.com/jquery-1.10.2.min.js
  12. // ==/UserScript==
  13.  
  14. jQuery.noConflict();
  15.  
  16. FullWalTab = new Array;
  17. // Exemple théorique: FullWalTab['IDBAT'] = 'http://lienversmonimage';
  18. // Exemple concret: (complétement inutile, certes, mais bon, osef.)
  19. FullWalTab['5988'] = 'http://www.dreadcast.net/images/batiments/batiment_5988.png';
  20.  
  21. function getIdFromUrl(urlBat){
  22. id = urlBat.split('_');
  23. id = id[id.length-1].split('.');
  24. id = id[0];
  25. return id;
  26. }
  27. function getBackground(urlBat){
  28. id = getIdFromUrl(urlBat);
  29. if(FullWalTab[id]){
  30. return FullWalTab[id];
  31. }
  32. return null;
  33. }
  34.  
  35. function changeBackground(newBackground){
  36. jQuery('#carte_fond').css('background-image', 'url('+newBackground+')');
  37. }
  38.  
  39. function changeBackgroundForBat(){
  40. carte = jQuery('#carte_fond');
  41. if(carte){
  42. background = getBackground(jQuery('#carte_fond').css("background-image"));
  43. if(background){
  44. changeBackground(background);
  45. }
  46. }
  47. }
  48.  
  49. jQuery(document).ready(function() {
  50. changeBackgroundForBat();
  51. });
  52.  
  53. Engine.prototype.displayMapInfoSave = Engine.prototype.displayMapInfo;
  54. Engine.prototype.displayMapInfo = function (html,is_default,force_show,custom_type,callback) {
  55. this.displayMapInfoSave(html,is_default,force_show,custom_type,callback);
  56. changeBackgroundForBat();
  57. }