e-hentai auto hyperlink

e-hentai auto convert urls in gallery comments into hyperlinks

La data de 04-06-2022. Vezi ultima versiune.

// ==UserScript==
// @name        e-hentai auto hyperlink
// @namespace   https://greasyfork.org/scripts/441145
// @version     1.2
// @description e-hentai auto convert urls in gallery comments into hyperlinks
// @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==

/* $ and $$ */
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);

/* main function */
(window.onload = function() {
    'use strict';

    const comments = $$(".c6");

    comments.forEach(function(comment){
        const before = comment.innerHTML;

        const after = before.replace(/(<a href=")?((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)))(">(.*)<\/a>)?/gi, function () {
            return '<a href="' + arguments[2] + '">' + (arguments[7] || arguments[2]) + '</a>'
        });

        comment.innerHTML = after;
    });
})();