MeFi Hover Favorites

Show who favorited a comment by hovering over it

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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       MeFi Hover Favorites
// @namespace  http://www.roufa.com/
// @version    0.15
// @description  Show who favorited a comment by hovering over it
// @match      http://*.metafilter.com/*/*
// @resource   jquicss   http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css
// @require    http://code.jquery.com/ui/1.10.3/jquery-ui.js
// ==/UserScript==

$(function() {
    var newCSS = GM_getResourceText ("jquicss");
    GM_addStyle (newCSS);
    GM_addStyle (".ui-tooltip {font-size:10pt;font-family:Calibri;}");

    var titles = {};
    $('div#page').on('mouseover', 'span[id^="favcnt"] a', function(evt) {
    	var link = evt.target;
        var href = link.href;
        if (titles[href]) return;
        link.title = '';
        titles[href]=true;
        $.get(href, null, function(d) {
        	var output = '';
            $('a', '<div>' + d.split('<div class="copy">')[1].split('</div>')[0] + '</div>').each(function(ix, el) { output += el.innerText + ', '; });
            output = output.substr(0, output.length-2);
            link.title = output;
            $(link).tooltip({content: output});
            $(link).tooltip("open");
        });
    });
    
    // [Add to] / [remove from] favorites (main post)
    $('div.copy').on('click', 'span[id^="fav"] a:eq(0)', function(evt){ // need to use the first one as there's no id or class for the add-to-favorites link (until AFTER it's been clicked once)
        var href = $('div.copy span[id^="favcnt"] a').attr('href');
        titles[href] = false;
    });

    // +/- button for comments
    $('div#page').on('click', 'a[id^="plusminus"]', function(evt){
        var favcntid = 'favcnt' + evt.target.id.split('plusminus')[1];
        var ancs = $('span#' + favcntid + ' a');
        if (ancs[0]) {
        	titles[ancs[0].href] = false;
        }
    });
});