better_drunkenslug_preview

Better Thumbnail preview for drunkenslug

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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         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();
        }
    });
})();