eMOARicons for Habtium

Agrega un panel extra de emoticonos en el formulario de respuesta o de nuevo tema en el foro de Habtium.

  1. // ==UserScript==
  2. // @name eMOARicons for Habtium
  3. // @namespace https://habtium.es
  4. // @description Agrega un panel extra de emoticonos en el formulario de respuesta o de nuevo tema en el foro de Habtium.
  5. // @icon https://greatest.deepsurf.us/system/screenshots/screenshots/000/003/503/original/moarlogo.png
  6. // @include https://*habtium.es/forum/reply/*
  7. // @include https://*habtium.es/forum/post/*
  8. // @include https://*habtium.es/forum/edit/*
  9. // @include https://*habtium.es/forum/topic/*
  10. // @authors Álex R. E. (habtium.es/AlexRE)
  11. // @copyright Copyleft(c) 2016, ARE
  12. // @version 0.5.5
  13. // @grant none
  14. // @license GPL - http://www.gnu.org/licenses/gpl-3.0.en.html
  15. // @credits Emoticonos extraídos de Forocoches, resubidos a Imgur
  16. // ==/UserScript==
  17.  
  18. /*-------------Definición de constantes y variables-------------*/
  19.  
  20. // Lista de todos los emoticonos disponibles y su número
  21. // A partir del i14 de HabboS
  22. const itemsPerGroup = 17;
  23. const emots = ['zwPISF9.gif',
  24. 'cimY9sd.gif',
  25. 'Ihbk5Yp.gif',
  26. '6jlUscE.gif',
  27. 'MY8GIXi.gif',
  28. 'VcdtbTb.gif',
  29. 'v6kG2hU.gif',
  30. 'nvd3ctp.gif',
  31. 'GS6c7ZA.gif',
  32. 'cWw3yBz.gif',
  33. 'M9kUhuf.gif',
  34. 'fSVHnTp.gif',
  35. 'Acg0LmY.gif',
  36. 'cb7EhG1.gif',
  37. 'ITNQ2Ax.gif',
  38. 'IAbUGBm.gif',
  39. 'RZJnz56.gif',
  40. 'Tcqdp8r.gif',
  41. 'JvoZTg7.gif',
  42. 'MAR5t8y.gif',
  43. '4A9bT6j.gif',
  44. '9y5FwHu.gif',
  45. '6y6I5JI.gif',
  46. 'O1KgE64.gif',
  47. 'ukYFhqP.gif',
  48. '0QqNjoz.gif',
  49. 'OVTgkx0.gif',
  50. 'nPxPPrR.gif',
  51. 'MSBjB2H.gif',
  52. '07L2Abs.gif',
  53. 'NbNdwff.gif',
  54. 's1WdD5l.gif',
  55. 'QlwLZEa.gif',
  56. 'OIvLtfL.gif',
  57. 'KI7TQop.gif'];
  58.  
  59. const emotCads = [':elrisas:', ':facepalm:', ':gaydude:', ':dale2:', ':nusenuse:', ':qmeparto:', ':roto2:', ':roto2cafe:', ':roto2gay:', ':roto2gaydude:', ':roto2nuse:', ':roto2qtemeto:', ':sherlock:', ':sisi3:', ':wikii:', ':uhh:', ':%:', ':pzz:', ':pp:', ':pbla:', ':ojitos:', ':mmm:', ':lO:', ':lengua:', ':jumm:', ':jum:', ':juju:', ':enfin:', ':cz:', ':chicle:', ':cejas:', 'asdf', '8D ', '8)', ':-.-:'];
  60. const emotCount = emots.length;
  61. const emotHost = "https://i.imgur.com/";
  62.  
  63.  
  64. /*-------------Comienzo del script-------------*/
  65. // Comprueba si estamos en un post viejo para sustituir emoticonos o no
  66. if(window.location.href.indexOf("topic") > -1)
  67. {
  68. var urlComp = '<img src=\"'
  69. var cadReg = new RegExp('','g');
  70. //Reemplaza otros emoticonos antiguos por emojis actuales
  71. document.body.innerHTML = document.body.innerHTML.replace(/:l:/g, '<span title=\"&amp;lt;3\" class=\"emoji emoji2764\"><\/span>');
  72. document.body.innerHTML = document.body.innerHTML.replace(/:arriquitaaun:/g, '<span title=\":dancer:\" class=\"emoji emoji1f483\"><\/span>');
  73. for(var x=0; x < emotCount; x++)
  74. {
  75. cadReg = RegExp(emotCads[x], 'g');
  76. urlComp = '<img src=\"' + emotHost + emots[x] + '\" \/>';
  77. document.body.innerHTML = document.body.innerHTML.replace(cadReg, urlComp);
  78. }
  79. }
  80. else
  81. {
  82. // Crea un nuevo bloque para emoticonos animados y lo acopla
  83. // al formulario de nueva respuesta.
  84. var emotGroup=document.createElement("div");
  85. var emotSeparator=document.createElement("br");
  86. emotGroup.setAttribute('class', 'button-group bbcode');
  87.  
  88. document.getElementById('content').getElementsByClassName('box box-biggest')[1].getElementsByClassName('body bbcode')[0].appendChild(emotSeparator);
  89. document.getElementById('content').getElementsByClassName('box box-biggest')[1].getElementsByClassName('body bbcode')[0].appendChild(emotGroup.cloneNode(true));
  90. document.getElementById('content').getElementsByClassName('box box-biggest')[1].getElementsByClassName('body bbcode')[0].appendChild(emotGroup.cloneNode(true));
  91.  
  92. // Genera un nuevo botón de añadir emoticono
  93. var emotInput=document.createElement("button");
  94. emotInput.setAttribute('type','button');
  95. emotInput.setAttribute('class', 'button grey small');
  96.  
  97. // Coloca tantos botones como emoticonos disponibles hay
  98. var j=0;
  99. for(var i=0;i < 2;i++)
  100. {
  101. k = i*emotCount;
  102. while(j-k < itemsPerGroup && j < emotCount)
  103. {
  104. emotInput.setAttribute('onclick', 'addSmiley(\'reply_body\',\'[img]' + emotHost + emots[j] + '[/img]\')');
  105. emotInput.innerHTML="<img height=\"20\" src=\"" + emotHost + emots[j] + "\" />";
  106. document.getElementById('content').getElementsByClassName('box box-biggest')[1].getElementsByClassName('body bbcode')[0].getElementsByClassName('button-group bbcode')[9+i].appendChild(emotInput.cloneNode(true));
  107. j++;
  108. }
  109. }
  110. }