SSC Better like button

additional "Like button" without reload whole post

Od 01.06.2017.. Pogledajte najnovija verzija.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name  SSC Better like button
// @author el nino
// @namespace el nino
// @description additional "Like button" without reload whole post
// @include http://www.skyscrapercity.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
// @version 1.1.0
// @grant none
// ==/UserScript==

var like_active = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvElEQVQ4jc3SMUoDARQE0OcSJFhIWCwsci4LsQgWnsIL5ACWwSpYpExlYW3hAQQJiARtl5xgUiQhURLJZkEcmGr+DP8Pn3+BcB4eQhVm4SVcZ61fhOelVoVR6K7EMryGbGE/3O7Q3sOZcLdjYB8OjsLUap36+CrQaVBfp8Bbg4BJgUGDgHuhFR4PKPAptEBoh2EN8zCcfNslC16Gj1+M03CVLbdsBh2HXvj8YbwJ7b3bCafL9x6Hsn6/f4U5kqizcoBXWVYAAAAASUVORK5CYII="; 


//Append like button
$("<img>", {
    "src": "data:image/png;base64," + like_active,
    "class": "fast-like", 
    "style": "display:inline; cursor: pointer;",
    "width": "16px", "height": "16px"})
    .appendTo(".dbtech-thanks-button-control");

$(".fast-like").click(function() {
    var postid = $(this).parent().data("postid");
    sendLike(postid);

});

function sendLike(postid){
    $.ajax({
        type: "POST",
        url: "http://www.skyscrapercity.com/thanks.php",
        data: {
            "securitytoken": SECURITYTOKEN,
            "do": "ajax",
            "action": "entry",            
            "varname": "likes",
            "contenttype": "post",
            "p": postid
        }
    }).done(function(data) {
        var tagData = $(data),
            origData = data;
        data = {
            thanksEntries: {},
            colorOptions: {}
        };
        var singleVals = {
            0: 'entries',
            1: 'actions',
            2: 'error'
        };
        if (tagData.find('colorOption').length) {
            tagData.find('colorOption').each(function() {
                var tagData2 = $(this);
                if (typeof data.colorOptions[tagData2.attr('varname')] == 'undefined') {
                    data.colorOptions[tagData2.attr('varname')] = {};
                }
                data.colorOptions[tagData2.attr('varname')][tagData2.attr('numclicks')] = {
                    color: tagData2.text(),
                    settings: tagData2.attr('settings')
                };
            });
        }
        if (tagData.find('thanksEntry').length) {
            tagData.find('thanksEntry').each(function() {
                data.thanksEntries[$(this).text()] = $(this).attr('numclicks');
            });
        }
        for (var i in singleVals) {
            data[singleVals[i]] = '';
            if (tagData.find(singleVals[i]).length) {
                data[singleVals[i]] = tagData.find(singleVals[i]).text();
            } else if (singleVals[i] != 'error') {
                data['error'] = origData;
            }
        }
        if (data.error) {
            alert(data.error);
            console.error(timeStamp() + "AJAX Error: %s", data.error);
            return true;
        }
        $('#dbtech_thanks_entries_' + postid).html(data.entries);
        $('#dbtech_thanks_actions_' + postid).html(data.actions);
        if (typeof data.thanksEntries != 'undefined') {
            thanksOptions.thanksEntries[postid] = data.thanksEntries;
            switch (thanksOptions.contenttype) {
                case 'post':
                    _colourPost(postid);
                    _displayPost(postid);
                    break;
            }
        }
        if (data.colorOptions) {
            thanksOptions.colorOptions = data.colorOptions;
        }
    });    
}