字幕发布助手

自动选择上传的字幕类型,根据片源名称生成标题

目前為 2022-12-17 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         字幕发布助手
// @namespace    https://github.com/Sunhelter/LearningFile/blob/master/UserScript/SubtvHelper.js
// @version      1.4
// @description  自动选择上传的字幕类型,根据片源名称生成标题
// @match        *://subhd.tv/upload*
// @author       Sunhelter
// @date         2021-08-25
// @charset		 UTF-8
// @license      MIT
// ==/UserScript==

(function() {
    var url = window.location.href;

    $(function() {
        $("#lang1").prop("checked", true);
        $("#lang2").prop("checked", true);
        $("#lang3").prop("checked", true);
        $("#shuang1").prop("checked", true);
        $("#from1").prop("checked", true);
        $("#format1").prop("checked", true);
        $("#format2").prop("checked", true);
        $("#sub_zu").val("14", true);
        $("#sub_text").val('翻译/时间轴招募中,请访问yysub.net\n\n字幕组目前无任何粉丝群及收费群,欢迎发布调轴的版本,但请勿删除制作名单及网址');

        var btn = document.createElement("button");
        btn.type = "button";
        btn.setAttribute('class', 'btn btn-primary btn-sm');
        btn.setAttribute('onclick', 'watch()');
        var btntxt = document.createTextNode("生成标题");
        btn.appendChild(btntxt);
        document.getElementById("submit").parentNode.appendChild(btn);

        var s = document.createElement("script");
        s.type = "text/javascript";
        s.class = "btn btn-primary btn-sm";
        s.textContent = "\
         function watch(){\
             var chi = $(\"#douban_re\").text();\
             if(chi.length > 0){\
                 if(chi.search(/\\s/) > 0){\
                   chi = chi.substring(0,chi.search(/\\s/));\
                 }\
                 else if(chi.search(/\\uFF08/) > 0) {\
                   chi = chi.substring(0,chi.search(/\\uFF08/));\
                 }\
             }\
             else {\
                 alert('请关联剧集');\
                 return false;\
             }\
\
             var eng = $(\"#sub_edition\").val();\
             if(eng.length > 0){\
                 var title = eng.substring(0,eng.search(/s\\d{1,2}e\\d{1,2}/i)).replace(/\\./g,' ');\
                 if(title.length > 0){\
                     var se = eng.match(/s\\d{1,2}e\\d{1,2}/i);\
                     var season = se[0].replace(/e\\d{1,2}/i,'').replace(/s/i,'');\
                     var epsoide = se[0].replace(/s\\d{1,2}/i,'').replace(/e/i,'');\
                     eng = '第' + SectionToChinese(season) + '季第' + SectionToChinese(epsoide) + '集 (' + firstUpperCase(title) + 'S' + season + 'E' + epsoide + ')';\
\
                     $(\"#tv\").prop(\"checked\", true);\
                     $(\"#sub_season\").val(parseInt(season));\
                     $(\"#sub_ep\").val(parseInt(epsoide));\
                 }\
                 else{\
                    title = eng.substring(0,eng.search(/.\\d{4}.\\d{3,4}p/ig)).replace(/\\./g,' ');\
                    eng = ' (' + title + ')';\
                     $(\"#mv\").prop(\"checked\", true);\
                 }\
             }\
             else {\
                 alert('请填写字幕版本');\
                 return false;\
             }\
\
             $(\"#sub_title\").attr(\"value\",fullTitle(chi, eng));\
         }\
\
         function fullTitle(chi, eng){\
             return chi + ' '+ eng + '【人人字幕】';\
         }\
\
         function firstUpperCase(str) {\
             return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());\
         }\
\
         function SectionToChinese(section){\
             var chnNumChar = [\"零\",\"一\",\"二\",\"三\",\"四\",\"五\",\"六\",\"七\",\"八\",\"九\"];\
             var chnUnitChar = [\"\",\"十\",\"百\",\"千\",\"万\",\"亿\",\"万亿\",\"亿亿\"];\
             var strIns = '', chnStr = '';\
             var unitPos = 0;\
             var zero = true;\
             while(section > 0){\
                 var v = section % 10;\
                 if(v === 0){\
                     if(!zero){\
                         zero = true;\
                         chnStr = chnNumChar[v] + chnStr;\
                     }\
                 }else{\
                     zero = false;\
                     strIns = chnNumChar[v];\
                     strIns += chnUnitChar[unitPos];\
                     chnStr = strIns + chnStr;\
                 }\
                 unitPos++;\
                 section = Math.floor(section / 10);\
             }\
             if(section < 20){\
                 chnStr = chnStr.replace('一十','十');\
             }\
             return chnStr;\
         }\
         ";
        document.head.appendChild(s);
    });
})();