JavLibrary Video Fetcher

这个脚本在浏览 javlibrary.com 网站时抓取视频链接,并在页面上显示这些链接。每个页面只显示一个视频链接,从而提高页面的可读性和使用体验。

Versione datata 17/10/2023. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         JavLibrary Video Fetcher
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  这个脚本在浏览 javlibrary.com 网站时抓取视频链接,并在页面上显示这些链接。每个页面只显示一个视频链接,从而提高页面的可读性和使用体验。
// @author       TT
// @match        www.javlibrary.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// ==/UserScript==

(function () {
    'use strict';

    var links = document.links;
    var addedLinks = [];
    for (var i = 0; i < links.length; i++) {
        (function (link) {
            var url = link.href
            if (url.includes('?v=j')) {
                url = url.replace("/?v=", "/videocomments.php?v=");
                fetch(url)
                    .then(response => response.text())
                    .then(html => {
                        var parser = new DOMParser();
                        var doc = parser.parseFromString(html, 'text/html');

                        var textNodes = doc.body.innerText.split("\n");
                        for (var j = 0; j < textNodes.length; j++) {
                            var text = textNodes[j];
                            var regex = /(http(s?):)([/|.|\w|\s|-])*\.(?:mp4)/g;
                            var matches = text.match(regex);
                            if (matches) {
                                for (var k = 0; k < matches.length; k++) {
                                    if (!addedLinks.includes(matches[k])) {
                                        var video = document.createElement('video');
                                        video.src = matches[k];
                                        video.width = 320;
                                        video.height = 240;
                                        video.controls = true;
                                        link.parentElement.parentElement.insertBefore(video, link.parentElement);
                                        addedLinks.push(matches[k]);
                                        break;
                                    }
                                }
                                if (matches.length > 0) break;
                            }
                        }
                    })
                    .catch(function (err) {
                        console.warn('Something went wrong.', err);
                    });
            }
        })(links[i]);
    }
})();