Detrollizer na pnet...
Ahoj,
upravena verze detrollizeru z debat, tak aby fungovala pro poradnu. Zacina to byt treba i tady. Enjoy!
PS: Pripadne bugy opravim...
Script pro Greasemonkey:
// ==UserScript==
// @name Detrollizer pro poradna.net
// @version 1
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==
// Script schova prispevky a vlakna zvolenych useru.
// U prispevku se vyuziva tag spoiler, aby nedoslo k naruseni struktury vlakna. Vlakna jsou odebrana z tabulky threadu.
// nastav promennou na true, pokud chces schovat hodnoceni prispevku
var HIDE_POST_RATING = false;
// nastav prezdivky useru, jejichz prispevky a vlakna chces schovat
// funguje pro registrovane i neregistrovane usery
var BLOCKED_USERS = ["Mlocik97", "MaSíčko"];
$(function () {
hidePostsRatings();
hideThreads();
hidePosts();
});
function hidePostsRatings() {
if (HIDE_POST_RATING) {
$("a.rate").hide();
}
}
function isBlocked(login) {
for (var i = 0; i < BLOCKED_USERS.length; i++) {
if (BLOCKED_USERS[i] === login) {
return true;
}
}
}
function hideThreads() {
$("td._createdBy").each(function () {
var nickElement = $(this).find("a:first");
var nickText = null;
if ($(this).has("a").length) {
nickText = nickElement.html();
} else {
nickText = $(this).html();
}
if (isBlocked(nickText)) {
$(this).parent().hide()
}
});
}
function hidePosts() {
$("article.reply").each(function () {
var nickElement = $(this).find("b:first");
var nickText = null;
if (nickElement.has("a").length) {
nickText = $(this).find("a:first").html();
} else {
nickText = nickElement.html();
}
if (isBlocked(nickText)) {
var postElement = $(this).find("div.body:first");
var postContent = postElement.html();
postElement.empty();
postElement.append(detrollizePostContent(postContent))
}
});
$('div.detrollizer').detrollize();
}
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);