HF Scripts - Thread Previewer

Allows you to preview threads before opening it. - Updated by Dr Steve Brule

As of 29.11.2016. See ბოლო ვერსია.

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 or Violentmonkey 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		HF Scripts - Thread Previewer
// @namespace 		xerotic/previewthread
// @description 	Allows you to preview threads before opening it. - Updated by Dr Steve Brule
// @include  		*hackforums.net/forumdisplay.php?fid=*
// @include  		*hackforums.net/search.php?action=results&sid=*
// @version  		1.1.0
// ==/UserScript==

function getPage(e) {
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest
    } else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
    }
    xmlhttp.open("GET", e, false);
    xmlhttp.send();
    var t = document.implementation.createHTMLDocument("HF Thread");
    t.documentElement.innerHTML = xmlhttp.responseText;
    return t
}

function loadPreview(e) {
    var t = getPage(tidElements[e].href);
    var n = document.createElement("div");
    if (!t.body.getElementsByClassName("post_body")[0]) {
        n.innerHTML = t.body.querySelectorAll('div[id^="pid"]')[0].innerHTML
    } else {
        n.innerHTML = t.body.getElementsByClassName("post_body")[0].innerHTML
    }
    n.style.border = "2px solid #0F5999";
    n.style.margin = "5px";
    n.style.padding = "6px";
    n.style.boxShadow = "0px 0px 5px 4px #1E1E1E";
    tidParents[e].parentNode.insertBefore(n, tidParents[e].nextSibling)
}
var tidElements = document.body.querySelectorAll('a[id^="tid"]');
tidParents = new Array;
for (var i = 0; i < tidElements.length; i++) {
    tidParents[i] = tidElements[i].parentNode;
    var newSpan = document.createElement("span");
    newSpan.innerHTML = "▼";
    newSpan.style.color = "#0F5999";
    newSpan.style.fontSize = "16px";
    newSpan.style.marginLeft = "7px";
    newSpan.style.cursor = "pointer";
    newSpan.id = i;
    tidParents[i].appendChild(newSpan);
    tidParents[i].addEventListener("click", function(e) {
        ele = e.srcElement;
        loadPreview(e.target.id);
        ele.parentNode.removeChild(ele)
    }, false)
}