LibraryThing reply preview (HTML)

Shows the message that's being replied to in a hover tooltip, including mark-up

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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        LibraryThing reply preview (HTML)
// @namespace   https://greasyfork.org/en/users/11592-max-starkenburg
// @description Shows the message that's being replied to in a hover tooltip, including mark-up
// @include     http*://*librarything.tld/topic*
// @include     http*://*librarything.com/topic*
// @include     http*://*librarything.tld/talktopic*
// @include     http*://*librarything.com/talktopic*
// @version     2
// @grant       none
// ==/UserScript==

jQuery("head").append('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>')  

jQuery("head").append('<style type="text/css"> \
  .ui-tooltip { padding: 8px 8px 0; background-color: #fff; position: absolute; z-index: 9999; box-shadow: 0 0 5px #888; min-width: 300px; max-width: 600px; max-width: calc(100% - 500px); }\
  .ui-tooltip h3 { font-size: 10px; line-height: normal; } \
  .ui-tooltip h3 .b { color: #000 !important; } \
  .ui-tooltip .mT { font-size: 10px !important; } \
  .ui-tooltip br { line-height: 8px; } \
  .ui-arrow { width: 70px; height: 12px; top: 100%; left: 0; overflow: hidden; position: absolute; }\
  .ui-arrow.top { top: auto; bottom: 100%; }\
  .ui-arrow:after { content: ""; background-color: #fff; position: absolute; top: -20px; width: 25px; height: 25px; margin-left: 20px; box-shadow: 0 0 5px #888; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); tranform: rotate(45deg); } \
  .ui-arrow.top:after { bottom: -20px; top: auto; } \
  </style>');

function waitForJQueryUI() {  
  if (window.jQuery.ui) {
    jQuery("#msgs").tooltip({
      items: ".mT a[href^='#']:not(.ed)",
      content: function() {
        var ref = jQuery(this).attr("href").substring(1);
        var ref = jQuery(".fp:has(a[name='" + ref + "'])");
        if (ref.length) {
          return ref.clone().find(".ed, .tj").remove().end().html();
        }
      },
      position: {
        my: "left-20 bottom-15",
        at: "left top",
        using: function(position, feedback) {
          jQuery( this ).css( position );
          jQuery("<div>")
            .addClass( "ui-arrow" )
            .addClass( feedback.vertical )
            .addClass( feedback.horizontal )
            .appendTo( this );
        }
      }
    });
  } else {
    setTimeout(waitForJQueryUI, 100);
  }
}

// There's an error if we don't wait for jQuery UI to get loaded before the .tooltip() call
waitForJQueryUI();