自动获取JAVLIB的字幕

自动获取JAVLIB的字幕,暂时只支持JAVLIB。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         自动获取JAVLIB的字幕
// @namespace    http://tampermonkey.net/
// @version      2.2.1
// @description  自动获取JAVLIB的字幕,暂时只支持JAVLIB。
// @author       bestYy
// @include     http*://*javlibrary.com/*
// @include     http*://*javlib.com/*
// @include     http*://*javl10.com/*
// @include     http*://*jav11b.com/*
// @include     http*://*13vlib.com/*
// @include     http*://*d21b.com/*
// @run-at      document-end
// @grant       GM_xmlhttpRequest
// @grant       GM_addStyle
// @require      https://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
    'use strict';
    GM_addStyle("#divZm{margin-left:70px;}");
    var japonxUrl = "https://www.japonx.net";
    $("#video_cast").after("<div id='divZm'>正在查询字幕...</div>");
    var my = {
    	getFh:function(){
            var fh = $("td.text").html();
            var star = $('#video_cast').find('span.star').find('a').html();
    		return {fh:fh, star:star};
    	},
    	getZm:function(fh, star){
    		GM_xmlhttpRequest({
    			method:"GET",
                url: japonxUrl + "/portal/index/search.html?k=" + fh,
                headers: {
                    'user-agent': 'mozilla/4.0 (compatible) greasemonkey',
                    'accept': 'application/atom+xml,application/xml,text/xml',
                },
    			onload:function(result){
                    //搜索番号
                     var doc = result.responseText;
                     doc = doc.replace(/[\r\n]/g,"");
                     var re = new RegExp('<ul id="works" class="normal clearfix">.*<li>.*<a href="(.*)".*<img.*' + star + '<\/a>');
                     var arr = doc.match(re);
    				 if(!arr){
    				 	$("#divZm").html("暂无字幕");
    				 	return ;
                     }
                     var fhUrl = japonxUrl + arr[1];
                     //搜索字幕
                     GM_xmlhttpRequest({
                        method:"GET",
                        url: fhUrl,
                        headers: {
                            'user-agent': 'mozilla/4.0 (compatible) greasemonkey',
                            'accept': 'application/atom+xml,application/xml,text/xml',
                        },
                        onload:function(result){
                             var doc = result.responseText;
                             var re2 = new RegExp(fh);
                             var re = /中文/;
                             var arr = doc.match(re);
                             var arr2 = doc.match(re2);
                             if(arr && arr2){
                                $("#divZm").html('<b>字幕下载地址:</b><a href="'+ fhUrl +'" target="_blank">'+ fhUrl +'</a><b>请复制地址在浏览器打开,否则会出现404</b>');
                                return ;
                             }
                             $("#divZm").html("暂无字幕");
                             return ;
                        },
                        onerror:function(e){
                            console.log('搜索字幕出现错误');
                        }
                    });
    			},
    			onerror:function(e){
    				console.log('搜索字幕出现错误');
    			}
    		});
        },
    };
    var info = my.getFh();
    console.log('info', info);
    my.getZm(info.fh, info.star);
})();