// ==UserScript==
// @name Wykopowy zwawijas
// @description Zwijanie i rozwijanie komentarzy pod znaleziskami
// @include http://www.wykop.pl/link/*
// @version 0.3
// ==/UserScript==
if (typeof $ == 'undefined') {
if (typeof unsafeWindow !== 'undefined' && unsafeWindow.jQuery) {
// Firefox
var $ = unsafeWindow.jQuery;
main();
} else {
// Chrome
addJQuery(main);
}
} else {
// Opera
main();
}
function addJQuery(callback) {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}
function main(){
window.fold = function (item){
item = $(item);
if(item.text().match('-')) item.text('[+]');
else item.text('[-]');
item.parent().find('ul').toggle();
}
$( document ).ready(function() {
var streams = $('ul.comments-stream > li');
//streams.prepend('[-]');
streams.each(function(i, item){
item = $(item);
var length = item.find('ul.sub > li').length;
if(length > 0){
item.find('div:first > div > div.author').append('Komentarzy: ' + length + '');
$(streams.get(i)).prepend('[-]');
}
});
});
}