e-hentai add karma link

e-hentai auto add karma link in [Karma Log] page

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        e-hentai add karma link
// @namespace   https://greasyfork.org/scripts/473762
// @version     1.1
// @description e-hentai auto add karma link in [Karma Log] page
// @author      fmnijk
// @match       https://e-hentai.org/*
// @icon        https://www.google.com/s2/favicons?domain=e-hentai.org
// @grant       none
// @run-at      document-end
// @license     MIT
// ==/UserScript==

/* main function */
(function() {
    'use strict';

    if (window.location.href !== 'https://e-hentai.org/logs.php?t=karma'){
        return false;
    }

    var th = document.createElement('th');
    th.textContent = 'Reply';
    th.style = 'text-align:left; border-bottom:1px solid #5C0D12; width:50px';
    var referenceNode = document.querySelector('body > div:nth-child(5) > table > tbody > tr:nth-child(1) > th:nth-child(4)');
    referenceNode.parentNode.insertBefore(th, referenceNode);

    var lastRowIndex = document.querySelector('body > div:nth-child(5) > table > tbody').rows.length;
    for (var i = 2; i <= lastRowIndex; i++) {
        var a = document.createElement('a');
        var href = document.querySelector('body > div:nth-child(5) > table > tbody > tr:nth-child(' + i + ') > td:nth-child(3) > a').href;
        var showuser = href.split('=')[1];
        a.href = 'https://e-hentai.org/dmspublic/karma.php?u=' + showuser;
        a.textContent = 'k+';
        var td = document.createElement('td');
        td.style = 'text-align:left; vertical-align:top';
        td.appendChild(a);
        referenceNode = document.querySelector('body > div:nth-child(5) > table > tbody > tr:nth-child(' + i + ') > td:nth-child(4)');
        referenceNode.parentNode.insertBefore(td, referenceNode);
    }
})();