JavLibrary Video Fetcher

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

Від 17.10.2023. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

(I already have a user style manager, let me install it!)

// ==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]);
    }
})();