Hello,
How can i hide this script for members? It's only for administrators/moderators.
It's give a button in the message to hide a message from a member:
And is it possible to move this icon after the delete button ?
Many thanks for your help. :)
How can i hide this script for members? It's only for administrators/moderators.
- Code:
(function($) {
'use strict';
$(function() {
if (!/^\/t(\d+)(p\d+-|-).*$/i.test(location.pathname)) {
return;
}
$('.post').each(function() {
var $post = $(this);
var config = {
link: $post.next().find('a[href^="/post?p="][href$="&mode=editpost"]'),
message: $post.attr('class').split('--')[1],
title: $post.find('.postdetails:not(.poster-profile)'),
content: $post.find('.postbody div').html()
};
if (/> only_admin/.test(config.title.text())) {
config.title
.html('[VERBORGEN BERICHT] alleen zichtbaar voor leden met moderatierechten!</u>.');
$post
.attr('id', 'only_admin-' + config.message.match(/[0-9]+/))
.css('opacity', '.6')
.find('.postbody .content')
.html((_userdata.user_level ? config.content : '<span style="font-weight: 700; color: #ccff00 !important; text-shadow: 1px 1px 4px rgb(0 0 0 / 20%); user-select: none;">[ Dit bericht is verborgen en alleen voor moderatoren te bekijken! ]</span>'));
}
if (_userdata.user_level !== 1 && _userdata.user_level !== 2) {
return;
}
if (!config.link.length) {
return;
}
$.get(config.link.attr('href'))
.done(function(context) {
var $textarea = $('#text_editor_textarea', context);
var isHide = $('#only_admin-' + config.message.match(/[0-9]+/));
if (!$textarea.length) return;
$('<img>', {
'src': (isHide.length ? 'https://i.servimg.com/u/f26/19/95/73/76/scre2611.png' : 'https://i.servimg.com/u/f26/19/95/73/76/scre2610.png'),
'role': 'button',
'class': 'p-hide',
'loading': 'lazy',
'title': (isHide.length ? 'Weergeef dit bericht' : 'Verberg dit bericht'),
'alt': (isHide.length ? 'Niet meer verbergen' : 'Verberg bericht')
})
.insertBefore($post.next().find('a[href^="/post"][href$="mode=editpost"]'))
.on('click', function(event) {
event.preventDefault();
var topicname = '> only_admin';
if (isHide.length) {
var renametopic = prompt('Maak onderstaand veld helemaal leeg om bericht terug te zetten voor leden!', topicname);
if (renametopic != null) {
topicname = renametopic;
}
}
$.post("/post", {
p: config.link.attr('href').replace(/^\/post\?p=(\d+)&.+/gi, '$1'),
mode: 'editpost',
subject: topicname,
message: $textarea.val(),
edit_reason: '',
attach_sig: 0,
notify: 0,
post: 1
}).done(function() {
location.reload(true);
}).fail(function() {
alert('[Erro]: Something went wrong when editing the post');
});
});
});
});
});
}(jQuery));
It's give a button in the message to hide a message from a member:
And is it possible to move this icon after the delete button ?
Many thanks for your help. :)
Last edited by Joost on Fri Dec 30, 2022 10:02 pm; edited 1 time in total