Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Diamond Forum+
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Add some useful features to Diamond RP forum!
  6. // @author You
  7. // @match https://forum.diamondrp.ru/*
  8. // @match http://forum.diamondrp.ru/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. const fonts_families = ["segoe print", "century gothic", 'MV BOLI'];
  14. const fonts_names = ["Segoe Print", "Century Gothic", 'MV Boli'];
  15.  
  16. function list_addFonts(_list) {
  17. var list = $(_list);
  18. fonts_families.forEach((ff, fi) => {
  19. let space = ff.includes(' ');
  20. let nff = space ? `'${ff}'` : ff;
  21.  
  22. let has = list.has(`li[role=presentation] a[data-cmd=fontFamily][data-param1=${nff}]`).length;
  23. if (!has) has = list.has(`li[role=presentation] a[data-cmd=fontFamily][data-param1='${ff}']`).length;
  24. if (!has) has = list.has(`li[role=presentation] a[data-cmd=fontFamily][data-param1="${ff}"]`).length;
  25.  
  26. if (!has) {
  27. list.append(`<li role="presentation"><a class="fr-command" tabindex="-1" role="option" data-cmd="fontFamily" data-param1="${nff}" style="font-family: ${nff}" title="${fonts_names[fi]}">${fonts_names[fi]}</a></li>`);
  28. }
  29. });
  30. }
  31.  
  32. $('div.fr-toolbar div.fr-dropdown-menu[aria-labelledby*=fontFamily-] ul[role=presentation]').each((_, _list) => {
  33. list_addFonts(_list);
  34. });
  35.  
  36. $('body').on('DOMNodeInserted', '.fr-dropdown-menu[aria-labelledby*=fontFamily-]', function (event) {
  37. let elem = $(event.target);
  38. if (elem.is('.fr-dropdown-menu[aria-labelledby*=fontFamily-]')) {
  39. list_addFonts(elem.find('ul[role=presentation]'));
  40. }
  41. });
  42.  
  43. })();
  44.  
  45. (function() {
  46. const prefixes = { 'Для ГА/ЗГА серверов': {4: 'На рассмотрении', 5: 'Рассмотрено'}};
  47. var prefixesTimer = null;
  48.  
  49. function list_addPrefixes(_list) {
  50. var list = $(_list);
  51.  
  52. Object.entries(prefixes).forEach(([groupn, gprefs]) => {
  53. if (groupn == '') {
  54. Object.entries(gprefs).forEach(([pid, name]) => {
  55. if (list.has(`option[value='${pid}']`).length == 0)
  56. list.append(`<option value="${pid}">${name}</option>`);
  57. });
  58. }
  59. else {
  60. if (list.has(`optgroup[label='${groupn}']`).length == 0) {
  61. let group = $(`<optgroup label="${groupn}"></optgroup>`);
  62. Object.entries(gprefs).forEach(([pid, name]) => {
  63. group.append(`<option value="${pid}">${name}</option>`);
  64. });
  65. list.append(group);
  66. }
  67. }
  68. });
  69. }
  70.  
  71. function timerHandler(_list) {
  72. var list = $(_list);
  73. list_addPrefixes(_list);
  74. }
  75.  
  76. $('body').on('DOMNodeInserted', 'select[name=prefix_id]', function (event) {
  77. if (prefixesTimer != null) clearInterval(prefixesTimer);
  78. prefixesTimer = setTimeout(timerHandler.bind(null, this), 100);
  79. });
  80. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement