Last active
June 1, 2019 19:15
-
-
Save seniorpreacher/63f4ee30620a7f273749071beee871a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name nCore - Thumbnail preview | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Adds cover image lext to list view | |
// @author You | |
// @match https://ncore.cc/torrents.php* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const setupStyle = () => { | |
document.querySelector('#main_all').style.margin = 'inherit'; | |
document.querySelector('#main_all').style.width = '100%'; | |
document.querySelector('#main_all .lista_all').style.margin = '0 10px 0 auto'; | |
const style = document.createElement("style"); | |
document.head.appendChild(style); | |
const sheet = style.sheet; | |
sheet.insertRule('.cover-img {position: relative; width: 109px; height: 160px; box-shadow: #00000050 0 0 15px; transition: all .8s ease}'); | |
sheet.insertRule('.cover-img:hover {transform: scale(1.8); box-shadow: #000000e0 0 0 20px 2px; z-index: 10}'); | |
sheet.insertRule('.cover-hover {background: #206f00}'); | |
sheet.insertRule('.cover-hover .box_nagy2 {background: inherit}'); | |
} | |
const run = function() { | |
setupStyle(); | |
document.querySelectorAll('.box_torrent').forEach((torrent_row, i) => { | |
const icon = torrent_row.querySelector('.infobar_ico'); | |
if(!icon){ | |
return; | |
} | |
const mouseover = icon.attributes[1].value.replace("mutat('", ''); | |
const coverImg = mouseover.substr(0, mouseover.indexOf("',")); | |
const newImg = document.createElement('div'); | |
newImg.classList.add('cover-img'); | |
newImg.style.left = (-462 + ((i % 4) * 114)) + 'px'; | |
newImg.style.top = (((i % 4) * -40) - ((i % 4)*2)) + 'px'; | |
newImg.style.background = `url(${coverImg}) #000 50% 50% no-repeat`; | |
newImg.style.backgroundSize = 'contain'; | |
newImg.addEventListener('mouseover', () => torrent_row.classList.add('cover-hover')); | |
newImg.addEventListener('mouseleave', () => torrent_row.classList.remove('cover-hover')); | |
torrent_row.appendChild(newImg); | |
}) | |
}; | |
run(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment