Reddit WebPreview

Webpage Preview like hoverzoom

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name       Reddit WebPreview
// @version    7.19.14
// @description  Webpage Preview like hoverzoom
// @match      *://www.reddit.com*/*
// @copyright  2014+,  Hans Strausl
// @namespace https://greasyfork.org/users/3445
// ==/UserScript==
var RWP_DEBUG = false;
var things, link, i, x, w, h, page, timeout = null;

function init(){
    setTimeout(function(){
        G("Reddit WebPreview Started");
        things = document.getElementsByClassName("thing link");
        for (i = 0; i < things.length; i++){
            link = things[i].getElementsByClassName("title may-blank")[0];
            link.onmouseover = function(e){
                if (!(this.className.search("hoverZoomLink") > -1)){
                    G(link);
                    
                    prvw(this, e.pageX);
                }
            };
        }
    }, 500);
}

window.onload = init();

function prvw(link, mouseX){
    timeout = setTimeout(function(){
        w = screen.width;
        h = screen.height - 200;
        x = (w / 2) - 150;
        G(w + " x " + h + " : " + x + " : " + (mouseX - 25));
        page = window.open(link.href,"","height=" + h + ",width=" + x + ",left=" + (mouseX - 25) + ",top=50");
    }, 500);
    link.onmouseout = function(e){
        clearTimeout(timeout);
        if (typeof page !== "undefined"){
            page.close();
        }
    };
    window.onbeforeunload = function(e){
        if (typeof page !== "undefined"){
            page.close();
        }
    }
}

function G(data){
    if (RWP_DEBUG === true){
        console.log(data);
    }
}