Greasy Fork is available in English.

SSC Better like button

additional "Like button" without reload whole post

2017-06-01 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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;
        }
    });    
}