Detrollizer 1.2
changelog:
+ opravena funkčnost detrollizace při stránkování v debatách
+ opravena funkčnost detrollizovaní příspěvku, který už obsahoval tag spoiler
// ==UserScript==
// @name debaty.net
// @namespace debaty
// @description Skryti prispevku vybranych uzivatelu na debaty.net
// @include http://debaty.net/*
// @version 1.2
// @grant none
// ==/UserScript==
// type usernames to hide
var blockedUsers = ["MaSo"];
$(document).ready(function() {
hideBlockedUsers();
});
$(document).ajaxComplete(function() {
hideBlockedUsers();
});
function hideBlockedUsers() {
//hide threads
$('.text-overflow').each(function(i, obj) {
var nickElement = $(this).find('a:first');
var nick = nickElement.html();
if (isBlocked(nick)) {
nickElement.parent().parent().css('display', 'none');
}
});
// hide posts
$('.details small:first-child').each(function(i, obj) {
var nickElement = $(this).find('a:first');
var nick = nickElement.html();
if (isBlocked(nick)){
var postElement = nickElement.parent().parent().parent().find('div:first');
var postContent = postElement.html();
// post has spoiler
if(postElement.find('div.spoiler').length != 0) {
postContent = postElement.find('div.spoiler').html();
}
postElement.html(detrollizePostContent(postContent))
}
});
$('div.detrollizer').detrollize();
}
function isBlocked(login) {
for (var i = 0 ; i < blockedUsers.length; i++){
if (blockedUsers[i] === login) {
return true;
}
}
return false;
}
function detrollizePostContent(content) {
return '<div class="detrollizer" style="display : none">' + content + '</div>'
}
(function($) {
$.fn.detrollize = function(settings) {
settings = jQuery.extend({
text: 'Detrollized!'
},settings);
this
.wrap('<div class="spoiler-wrapper" />')
.parent()
.prepend(
$('<div class="spoiler_title">')
.click(function() {
$(this).parent().toggleClass('spoiler-expanded');
$(this).next('.detrollizer').slideToggle();
})
.text(settings.text)
)
return this;
};
})(jQuery);