Hentai in New Tabs by One Click

Make Lewding Easier

Ajankohdalta 26.9.2022. Katso uusin versio.

// ==UserScript==
// @name         Hentai in New Tabs by One Click
// @namespace    https://github.com/CinnamonJui
// @version      0.1.0
// @description  Make Lewding Easier
// @author       CinnamonJui
// @match        https://exhentai.org/g/*
// @match        https://e-hentai.org/g/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=e-hentai.org
// @grant        none
// @license MIT
// ==/UserScript==

/* jshint esversion:6 */

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}

(function() {
    'use strict';
    const rowNumSec = document.getElementById('gdo2');
    addGlobalStyle('#gdo2 { width: 350px !important; }');

    const newTabBtn = document.createElement('div');
    newTabBtn.textContent = 'New Tab';
    newTabBtn.className = 'tha nosel';
    newTabBtn.onclick = (e) => {
        e.preventDefault();
        const gallary = document.getElementById('gdt');
        const imgs = Array(...gallary.children).filter( e => e.className === 'gdtl');
        const links = imgs.map(e => e.children[0].href);
        links.map(l => window.open(l, '_blank'));
    };

    rowNumSec.append(newTabBtn);
})();