better_drunkenslug_preview

Better Thumbnail preview for drunkenslug

// ==UserScript==
// @name         better_drunkenslug_preview
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Better Thumbnail preview for drunkenslug
// @author       takuto
// @match        https://drunkenslug.com/*
// @grant        none
// @license MIT
// ==/UserScript==


(function() {
    'use strict';

    function createImagePreview(link) {
        let div = document.createElement('div');
        div.style.display = 'inline-block';
        div.style.margin = '10px';

        let img = document.createElement('img');
        img.src = link.href;
        img.style.maxWidth = '400px';
        img.style.maxHeight = '400px';
        img.style.display = 'block';

        div.appendChild(img);
        link.parentNode.insertBefore(div, link.nextSibling);
    }

    let links = document.querySelectorAll('a[href]');
    links.forEach(link => {
        if (link.href.match(/\.(jpeg|jpg|gif|png)$/)) {
            createImagePreview(link);
        }
    });
})();

(function() {
    'use strict';
    function containsText(node, text) {
        return node && node.textContent.includes(text);
    }

    let rows = document.querySelectorAll('tr');

    rows.forEach(row => {
        let containsBtnsDiv = row.querySelector('div.btns');

        let containsThumbnail = Array.from(row.querySelectorAll('a')).some(link => link.textContent.trim() === 'Thumbnail');

        if ((containsBtnsDiv && !containsThumbnail)) {
            row.remove();

//        let contains2160p = containsText(row, '2160');
//        let male = containsText(row, 'a.b.multimedia.erotica.male');
//
//        if ((containsBtnsDiv && !containsThumbnail) || contains2160p || male) {
//            row.remove();

        }
    });
})();

(function() {
    'use strict';

    let links = document.querySelectorAll('a');

    links.forEach(link => {
        if (link.textContent.trim() === 'Thumbnail') {
            link.remove();
        }
    });
})();