sup/tg/ Archive Quote Functions

Add Inline Quoting (mouse click) ~ Quote Preview (mouse hover) ~ Backlinks ~ Inline Image Expansion to suptg archives

Verze ze dne 05. 06. 2014. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        sup/tg/ Archive Quote Functions 
// @namespace   https://greasyfork.org/users/2457-meganega 
// @description Add Inline Quoting (mouse click) ~ Quote Preview (mouse hover) ~ Backlinks ~ Inline Image Expansion to suptg archives
// @include     http://suptg.thisisnotatrueending.com/archive/* 
// @require     http://code.jquery.com/jquery-latest.min.js 
// @version     1.13 
// @grant       none 
// ==/UserScript==
$(document) .ready(function () {
    /* Create Backlinks */
    $('blockquote a.quotelink') .each(function () {
        var t = $(this) .attr('href') .replace(/#p/, '');
        var q = $(this) .parents("blockquote") .eq(0) .attr('id') .replace(/m/, '');
        if ($('#bl' + t) .length == 0) {
            $('#pi' + t + ' span.postNum.desktop') .after($('<div>') .attr('id', 'bl' + t) .addClass('backlink_'));
        }
        $('#bl' + t) .append($('<span>') .attr('id', 's' + t) .append($('<a>') .attr('href', '#p' + q) .addClass('quotelink') .append('>>' + q)));
    });
    /* Backlink Inline Quote */
    $('div.backlink_ a.quotelink') .click(function (event) {
        if (event.shiftKey) {
            event.preventDefault();
            window.location = this;
            return ;
        }
        event.preventDefault();
        var q = $(this) .attr('href') .replace(/#p/, '');
        var t = $(this) .parent() .attr('id') .replace(/s/, '');
        if ($(this) .parents('#pi' + t) .siblings('blockquote#m' + t) .children('[id^=f' + q + ']') .length) {
            $(this) .parents('#pi' + t) .siblings('blockquote#m' + t) .children('[id^=f' + q + ']') .remove();
            $(this) .removeClass('qLinkOpen');
        } else {
            $(this) .parents('#pi' + t) .siblings('blockquote#m' + t) .prepend($('#p' + q) .clone(true) .attr('id', 'f' + q + 't' + t));
            $(this) .addClass('qLinkOpen');
            $(this) .parents('#pi' + t) .siblings('blockquote#m' + t) .children('[id^=f' + q + ']') .find('[id$=t' + q + ']') .remove();
        }
    });
    /* Backlink Quote Preview */
    $('div.backlink_ a.quotelink') .hover(function (event) {
        var q = $(this) .attr('href') .replace(/#p/, '');
        var t = $(this) .parent() .attr('id') .replace(/s/, '');
        $(this) .parent() .after($('#p' + q) .clone() .addClass('qPreview') .attr('id', '') .css('margin-top', $(this) .height() * 1.6 + 'px'));
        $(this) .parent() .siblings('.qPreview') .find('[id$=t' + q + ']') .remove();
        var o = $('#p' + q) .width(),
        p = $(this) .parent() .siblings('.qPreview') .width(),
        po = $(this) .parent() .siblings('.qPreview') .offset() .left,
        w = $(window) .width();
        if (po / w > 0.7 || p / o < 0.4) {
            $('.qPreview') .css('margin-left', '-' + (parseInt(o) + $(this) .width() * 0.15) + 'px');
        }
        if ($('.qPreview') .offset() .left < 0) {
            $('.qPreview') .css({
                'margin-left': '0',
                'left': '0'
            });
        }
        var pb = ($(window).height() + $(window).scrollTop()) - ($('.qPreview').offset().top + $('.qPreview').height());
        if(pb < 0){
            $(".qPreview").css("margin-top", (parseInt(pb) + 10) +"px");
        }
    }, function (event) {
        $('.qPreview') .remove();
    });
});
/* Inline Quote */
$('blockquote a.quotelink') .click(function (event) {
    if (event.shiftKey) {
        event.preventDefault();
        window.location = this;
        return ;
    }
    event.preventDefault();
    var qPost = $(this) .attr('href') .replace('#p', '');
    var tPost = $(this) .parent() .attr('id') .replace(/[a-z]/, '');
    if ($(this) .next('[id^=f' + qPost + ']') .length) {
        $(this) .next('[id^=f' + qPost + ']') .remove();
        $(this) .removeClass('qLinkOpen');
    } else {
        if ($('#p' + qPost) .hasClass('op')) {
            $(this) .after($('#p' + qPost) .clone(true) .attr('id', 'f' + qPost + 't' + tPost) .addClass('reply'));
            $(this) .addClass('qLinkOpen');
            $(this) .next('[id^=f' + qPost + ']') .find('[id$=t' + qPost + ']') .remove();
        } else {
            $(this) .after($('#p' + qPost) .clone(true) .attr('id', 'f' + qPost + 't' + tPost));
            $(this) .addClass('qLinkOpen');
            $(this) .next('[id^=f' + qPost + ']') .find('[id$=t' + qPost + ']') .remove();
        }
    }
});
/* Quote Preview */
$('blockquote a.quotelink') .hover(function (event) {
    var qPost = $(this) .attr('href') .replace('#p', '');
    var tPost = $(this) .parent() .attr('id') .replace(/[a-z]/, '');
    var linkOffset = $('div#p' + tPost) .children('blockquote#m' + tPost) .children('a[href=#p' + qPost + ']') .offset() .left + 10;
    if ($('#p' + qPost) .hasClass('op')) {
        $(this) .before($('#p' + qPost) .clone() .addClass('qPreview reply') .attr('id', ''));
        $(this) .siblings('.qPreview') .find('[id$=t' + qPost + ']') .remove();
    } else {
        $(this) .before($('#p' + qPost) .clone() .addClass('qPreview') .attr('id', ''));
        $(this) .siblings('.qPreview') .find('[id$=t' + qPost + ']') .remove();
    }
    var qpheight = $('.qPreview') .height();
    $('.qPreview') .attr('style', 'margin-top: -' + qpheight / 2 + 'px !important; margin-left: ' + linkOffset + 'px !important;');
    var pb = ($(window) .height() + $(window) .scrollTop()) - ($('.qPreview') .offset() .top + qpheight);
    var pt = $('.qPreview') .offset() .top - $(window) .scrollTop();
    qpheight = $('.qPreview') .height();
    if (pb < 0) {
        var pos = qpheight / 2 - pb + 10;
        $('.qPreview') .attr('style', 'margin-top: -' + pos + 'px !important; margin-left: ' + linkOffset + 'px !important;');
    } else if (pt < 0) {
        var pos = qpheight / 2 + pt - 10;
        $('.qPreview') .attr('style', 'margin-top: -' + pos + 'px !important; margin-left: ' + linkOffset + 'px !important;');
    }
}, function (event) {
    $('.qPreview') .remove();
});
/* Inline Image Expansion */
$('a.fileThumb') .click(function (event) {
    event.preventDefault();
    if ($(this) .hasClass('image_expanded')) {
        $(this) .find('.expImage') .remove();
        $(this) .children('img:first') .css('display', 'block');
        $(this) .removeClass('image_expanded');
    } else {
        var imgLink = $(this) .attr('href');
        var imgDim = $(this) .siblings('.fileText') .html() .replace(/<a.*a>/, '') .match(/[0-9]{1,6}x[0-9]{1,6}/);
        var imgW = imgDim[0].replace(/x[0-9]{1,6}/, '');
        var imgH = imgDim[0].replace(/[0-9]{1,6}x/, '');
        if (imgW > $(window) .width()) {
            imgH = (($(window) .width() - ($(this) .offset() .left * 2)) / imgW) * imgH;
            imgW = $(window) .width() - ($(this) .offset() .left * 2);
        }
        $(this) .children('img:first') .css('display', 'none');
        $(this) .addClass('image_expanded') .children('img:first') .after($('<img>') .attr({
            'src': imgLink,
            'href': imgLink
        }) .css({
            'width': imgW + 'px',
            'height': imgH + 'px'
        }) .addClass('expImage'));
    }
});
var css = $('<link>') .attr({
    'rel': 'stylesheet',
    'type': 'text/css',
    'href': 'data:text/css,' +
    '.qPreview { position: absolute; font-size: 10pt; display: inline-block !important;}' +
    '.postContainer, .postInfo:after { content: \'\'; display: block; clear: both; }' +
    '.backlink_ > span { font-size: 80%; margin: 0 0.4em 0 0; }' +
    '.backlink_ { display: inline; margin-left: 0.2em; }' +
    'a.qLinkOpen{ opacity: 0.5; }' +
    'div.reply{ border-style: solid; border-width: 1px; border-color: rgb(180,180,180) !important; }' +
    'a.quotelink{ color: rgb(20,80,100) !important; }' +
    '.backlink_ span{ display: inline-block; }'
}) .appendTo('head');