Even Better Erome download links

Exposes media-download links for erome media galleries

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name Even Better Erome download links
// @namespace greasyfork.org
// @icon https://www.erome.com/android-chrome-192x192.png
// @description Exposes media-download links for erome media galleries
// @match http://erome.com/*
// @match http://*.erome.com/*
// @match https://erome.com/*
// @match https://*.erome.com/*
// @grant none
// @run-at document-end
// @copyright 2024 hltl
// @grant        none
// @author the-juju & hltl
// @version 1.0.1
// @license MIT
// Credits : https://greasyfork.org/en/scripts/415766-erome-download-links/
// Credits : https://sleazyfork.org/en/scripts/426236-better-erome-download-links

// ==/UserScript==

(function() {
    'use strict';

    var addLink = function(media) {
        var tagName = media.tagName;
        var src = tagName === 'IMG' ? media.getAttribute('data-src') : '';

        if (tagName === 'VIDEO') {
            var sourceElement = media.querySelector('source');
            src = !src && sourceElement ? sourceElement.src : '';
        }

        // Exit early if the element is the blur image
        if(media.parentElement.getAttribute('class') == "img-blur"){
            return
        }

        var br = document.createElement('br');
        var link = document.createElement('a');
        link.setAttribute('href', src);
        link.download = '';
        link.textContent = tagName + ': ' + src;
        link.target = '_blank';
        link.rel = 'noopener';
        media.parentElement.parentElement.appendChild(link);
        media.parentElement.parentElement.appendChild(br);
    }

    var init = function() {
        var mediaElements = document.querySelectorAll('.media-group .video video, .media-group .img img');
        for (var i = 0; i < mediaElements.length; i++) {
            var media = mediaElements[i];
            addLink(media);
        }
    }

    window.addEventListener('load', init, false);
    document.addEventListener('DOMContentLoaded', init, false);
})();