pornolab torrentPreview

Allows to display torrent's poster image as preview on search page when hover over link

Αυτός ο κώδικας δεν πρέπει να εγκατασταθεί άμεσα. Είναι μια βιβλιοθήκη για άλλους κώδικες που περιλαμβάνεται μέσω της οδηγίας meta // @require https://update.sleazyfork.org/scripts/412272/853145/pornolab%20torrentPreview.js

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         pornolab torrentPreview
// @version      1.0.0
// @author       ducklover
// @description  Allows to display torrent's poster image as preview on search page when hover over link
// @copyright    2020, ducklover (https://openuserjs.org/users/ducklover)
// @include      /^https?:\/\/pornolab\.net\/forum\/(tracker|viewforum).*/
// @license      MIT
// @run-at       document-end
// ==/UserScript==

function getPic(e) {
  if (
    (e.target.classList.contains("tLink") ||
      e.target.classList.contains("tt-text")) &&
    !e.target.querySelector(".customImg")
  ) {
    let url =
      "https://pornolab.net/forum" + e.target.getAttribute("href").slice(1);

    let r = new XMLHttpRequest();
    r.open("GET", url, false);
    r.send();

    let imgSrc = new DOMParser()
      .parseFromString(r.responseText, "text/html")
      .querySelector(".postImg").title;

    let div = document.createElement("div");
    div.style.cssText = `position: absolute; 
		                     width: 460px; 
							 height: 300px; 
							 left: 0; 
							 z-index: 10;`;

    e.clientY < 300 ? (div.style.bottom = "auto") : (div.style.bottom = "100%");
    div.className = "customImg";

    let img = document.createElement("img");
    img.setAttribute("src", imgSrc);
    img.style.cssText = `width: 100%;
		                     height: 100%;
							 object-fit: contain;`;

    div.appendChild(img);

    e.target.style.position = "relative";
    e.target.appendChild(div);
  } else if (
    (e.target.classList.contains("tLink") ||
      e.target.classList.contains("tt-text")) &&
    e.target.querySelector(".customImg")
  ) {
    e.target.querySelector(".customImg").style.display = "block";

    if (e.clientY < 300) {
      e.target.querySelector(".customImg").style.bottom = "auto";
    } else {
      e.target.querySelector(".customImg").style.bottom = "100%";
    }
  }
}

function hidePic(e) {
  if (
    (e.target.classList.contains("tLink") ||
      e.target.classList.contains("tt-text")) &&
    e.target.querySelector(".customImg")
  ) {
    e.target.querySelector(".customImg").style.display = "none";
  }
}

window.addEventListener("mouseover", getPic);
window.addEventListener("mouseout", hidePic);