Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Diamond Forum+
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Add some useful features to Diamond RP forum!
- // @author You
- // @match https://forum.diamondrp.ru/*
- // @match http://forum.diamondrp.ru/*
- // @grant none
- // ==/UserScript==
- (function() {
- const fonts_families = ["segoe print", "century gothic", 'MV BOLI'];
- const fonts_names = ["Segoe Print", "Century Gothic", 'MV Boli'];
- function list_addFonts(_list) {
- var list = $(_list);
- fonts_families.forEach((ff, fi) => {
- let space = ff.includes(' ');
- let nff = space ? `'${ff}'` : ff;
- let has = list.has(`li[role=presentation] a[data-cmd=fontFamily][data-param1=${nff}]`).length;
- if (!has) has = list.has(`li[role=presentation] a[data-cmd=fontFamily][data-param1='${ff}']`).length;
- if (!has) has = list.has(`li[role=presentation] a[data-cmd=fontFamily][data-param1="${ff}"]`).length;
- if (!has) {
- 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>`);
- }
- });
- }
- $('div.fr-toolbar div.fr-dropdown-menu[aria-labelledby*=fontFamily-] ul[role=presentation]').each((_, _list) => {
- list_addFonts(_list);
- });
- $('body').on('DOMNodeInserted', '.fr-dropdown-menu[aria-labelledby*=fontFamily-]', function (event) {
- let elem = $(event.target);
- if (elem.is('.fr-dropdown-menu[aria-labelledby*=fontFamily-]')) {
- list_addFonts(elem.find('ul[role=presentation]'));
- }
- });
- })();
- (function() {
- const prefixes = { 'Для ГА/ЗГА серверов': {4: 'На рассмотрении', 5: 'Рассмотрено'}};
- var prefixesTimer = null;
- function list_addPrefixes(_list) {
- var list = $(_list);
- Object.entries(prefixes).forEach(([groupn, gprefs]) => {
- if (groupn == '') {
- Object.entries(gprefs).forEach(([pid, name]) => {
- if (list.has(`option[value='${pid}']`).length == 0)
- list.append(`<option value="${pid}">${name}</option>`);
- });
- }
- else {
- if (list.has(`optgroup[label='${groupn}']`).length == 0) {
- let group = $(`<optgroup label="${groupn}"></optgroup>`);
- Object.entries(gprefs).forEach(([pid, name]) => {
- group.append(`<option value="${pid}">${name}</option>`);
- });
- list.append(group);
- }
- }
- });
- }
- function timerHandler(_list) {
- var list = $(_list);
- list_addPrefixes(_list);
- }
- $('body').on('DOMNodeInserted', 'select[name=prefix_id]', function (event) {
- if (prefixesTimer != null) clearInterval(prefixesTimer);
- prefixesTimer = setTimeout(timerHandler.bind(null, this), 100);
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement