NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Zwin mirko
// @include http://www.wykop.pl/mikroblog/*
// @version 1.0.2
// @grant none
// ==/UserScript==
// console.log('Start');
// First click
$('.more').on('click', '.affect.ajax', function() {
addRozwinLink(this);
});
// Click on zwiń
$(document).on('click','.more .zwin', function(e) {
e.preventDefault();
// Get post
var post = $(this).parent().parent().parent();
// Hide all comments except link with: więcej komentarzy
post.find('li:not(:last)').hide();
// Replace 'zwin' with 'wiecej komentarzy'
var t = $(this);
// Add więcej komentrzy
t.parent().html('<a href=\"'+ t.attr('data-url') + '\" data-ajaxurl=\"' + t.attr('data-ajaxurl') + ' \" id=\'rozwin\' class="">' + t.attr('data-text') + '</a>');
// Scroll to post
var target = post.parent();
$('html, body').animate({scrollTop: target.offset().top}, 1000);
});
// Click on rozwin
$(document).on('click', '.more #rozwin', function(e) {
e.preventDefault();
var t = $(this);
t.addClass('affect ajax');
t.trigger('click');
addRozwinLink(this);
});
function addRozwinLink(t) {
var p = $(t).parent().parent().parent();
var wiecej = ($(t).parent().html());
var link = $(t);
var data_ajaxurl = link.attr('data-ajaxurl');
var url = link.attr('href')
var text = link.html();
var add = '<li><p class=\"more\"><a href=\"\" class=\'zwin\' data-ajaxurl=\'' + data_ajaxurl + '\' data-url=\'' + url + '\' data-text=\'' + text + '\'>zwiń komentarze <i class=\"fa fa-chevron-up\"></i></a></p></li>';
// Add link: zwiń komentarze
p.delay(2000).queue(function(next) {
$(this).append(add).children(':last').hide().slideDown(500);
next();
});
};