Show Mandiner Comments

Userscript for showing mandiner.hu's quoted comments / replies

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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 Show Mandiner Comments
// @name:hu Mandiner Hozzászólás Mutató
// @license MIT
// @description	Userscript for showing mandiner.hu's quoted comments / replies
// @description:hu	Felhasználói szkript a mandiner.hu idézett hozzászólásainak / válaszainak megjelentéséhez
// @icon	https://mandiner.hu/images/favicon.png
// @version	1.2
// @include	https://*mandiner.hu/cikk/*
// @grant   none
// @namespace https://greasyfork.org/users/412587
// ==/UserScript==

let myStyle = document.createElement('style');
myStyle.innerHTML = '.commentToolTips { position: absolute; z-index: 9999; text-align: left; background-color: #000000bb; color: #fff; border: 1px solid #000; border-radius: 10px; margin-top: 5px; padding: 5px; }';
document.querySelector('head').appendChild(myStyle);

let commentLinks = document.querySelectorAll('.jump-comment');
for (let commentLink of commentLinks) {
	commentLink.onmouseover = function() {
		let xhr = new XMLHttpRequest();
		xhr.onreadystatechange = function() {
			if (this.readyState == 4 && this.status == 200) {
				let comment = JSON.parse(xhr.responseText).Content,
					commentToolTip = document.createElement('div');
				commentToolTip.setAttribute('id', 'commentToolTip_' + commentLink.getAttribute('data-id'));
				commentToolTip.classList.add('commentToolTips');
				commentToolTip.innerHTML = comment;
				if (commentLink.parentNode.nodeName === 'B') {
					commentLink.parentNode.parentNode.insertBefore(commentToolTip, commentLink.nextSibling);
				} else {
					commentToolTip.style.right = '0';
					commentLink.parentNode.insertBefore(commentToolTip, commentLink.nextSibling);
				}
			}
		};
		xhr.open('GET','https://mandiner.hu/comment/' + commentLink.getAttribute('data-id'));
		xhr.send();
	};
  
	commentLink.onmouseout = function() {
		let commentToolTips = document.querySelectorAll('.commentToolTips');
		console.log(commentToolTips);
		for (let commentToolTip of commentToolTips) {
			commentToolTip.parentNode.removeChild(commentToolTip);
		}
	
	};
}