自动获取JAVLIB的字幕

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

As of 2018-07-24. See the latest version.

// ==UserScript==
// @name         自动获取JAVLIB的字幕
// @namespace    http://tampermonkey.net/
// @version      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";
    var my = {
    	getFh:function(){
    		var fh = $("td.text").html();
    		return fh;
    	},
    	getZm:function(fh){
    		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;
                     var re = /<ul id="works" class="normal clearfix">\s+<li>\s+<a href="(.*)"/;
                     var arr = doc.match(re);
    				 if(!arr){
    				 	$("#video_cast").after("<div id='divZm'>暂无字幕</div>");
    				 	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){
                                $("#video_cast").after('<div id="divZm"><a href="'+ fhUrl +'" target="_blank">字幕下载</a></div>');
                                return ; 
                             }
                             $("#video_cast").after("<div id='divZm'>暂无字幕</div>");
                             return ;
                        },
                        onerror:function(e){
                            console.log('搜索字幕出现错误');
                        }
                    });
    			},
    			onerror:function(e){
    				console.log('搜索字幕出现错误');
    			}
    		});
        },
    };
    var fh = my.getFh();
    my.getZm(fh);
})();