js脚本-从蛋糕英语中提取对话字幕

将蛋糕英语中的字幕提取出来,打印后便于复习背诵。
需要使用油猴之类的扩展调用

// ==UserScript==
// @name 蛋糕英语自动提取对话
// @namespace cake
// @match http://pap.baicizhan.com/*
//@require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
// 
// 


$(document).ready(function(){
   $("body").css('height','90%');
  
});
var btn05=$("<input type='button' id='wzmBtn'  value='提取文本'   style='height:50px;font-size: 0.4rem'>");
$("body").append(btn05);

$("div.page-sentence-words-341gD").after(btn05);
document.getElementById("wzmBtn").addEventListener("click", function(){
    
  showtext();
});
var area01=$("<input id='area01' >");
$("body").append(area01);
var area02=$("<textarea id='area02' style='height:400px;width:100%;font-size: 0.4rem'></textarea>");
$("body").append(area02);
function showtext(){
  text = '';
            $t = $("span").each(function() {
                //text += $(this).children("span")html();
                //div.group-2PoM9  contents()
                text += $(this).html();
            });
            var shorttext = (delsub(text, "<i>"));
            shorttext = delsub(shorttext, "</i>");  
            shorttext = delsub(shorttext, "  ")
            console.log(shorttext);
  document.getElementById("area01").value+='\n'+shorttext;
  $("#area02").html(document.getElementById("area01").value);
  $("div.page-sentence-words-341gD").after(area02);
  $("i.mod-next-1LINN").parent().after(btn05);
  
}

 function delsub(father, sub) {
            var newfather = father;
            for (var i in father) {
                //console.log(i, father[i]);
            }
            var n = newfather.length;
            var delflag = true;
            var t = 0;
            do {
                var f = newfather.replace(sub, ' ');
                if (f.length < newfather.length) {
                    newfather = f;
                    delflag = true;
                    t++;

                } else {
                    delflag = false;
                }
            }
            while (delflag);
            return newfather;
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值