// ==UserScript==
// @name SD网络学院(个人备用464)
// @namespace **************
// @version 6.66
// @match *.dtdjzx.gov.cn/course/special/*
// @match *.dtdjzx.gov.cn/*
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_openInTab
// @license MIT
// @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @description 咖啡备用 谢绝下载
// ==/UserScript==
//本脚来自作者542714117,在基础上增加了共机464节课,时间短的视频大部分在前面
//自定义课程列表 保存课程 看完的视频注意手工删除
var videos = [
"3512721966425446482",
"3512151160968456844",
"3512145430861330445",
"3512014600092531863",
"3512015160585749110",
"3512013521359474880",
"3512013126222481482",
"3535570976047644630",
"3535543400369490054",
"3534825219476684908",
"3534795263187093333",
"3534292266682158272",
"3532551731554556804",
"3532235603087204042",
"3531137562687054119",
"3531137465840578695",
"3531137459607838005",
"3531137444575459469",
"3531137437923280178",
"3531137431690555228",
"3531137425248096187",
"3531137418595932935",
"3531137412153480421",
"3531137367266043702",
"3531137358676111548",
"3529212740881102038",
"3529232639254868131",
"3525895329524230333",
"3525007416833882125",
"3523293237924081794",
"3523292542265205801",
"3514245420333145024",
"3514204203679484609",
"3512019384686093982",
"3512016962324534689",
"3512765139839355373",
"3512743593733259814",
"3512705098344049123",
"3512029318249197339",
"3512015559321453135",
"3512020247278257281",
"3512020239384576024",
"3512019238657209880",
"3512018920829628369",
"3512018518553931133",
"3512017011020407693",
"3512016990241816623",
"3512016953038346509",
"3544468790588737014",
"3535568738529057449",
"3535568734074714676",
"3535568702021837729",
"3535568680387610664",
"3535398851097667633",
"3535398838212769258",
"3535398833917795335",
"3535398827315963165",
"3535398823020987190",
"3535398818726030450",
"3535398801705547789",
"3535398786673162253",
"3535383941328415630",
"3535383934885967204",
"3535383926296020333",
"3535383872608938424",
"3535383866166487915",
"3535383859237501969",
"3535383852795037736",
"3535383831320210232",
"3535355618166573493",
"3534825276418560409",
"3534825249541468425",
"3534825244206311101",
"3534825230214105180",
"3534825202296825913",
"3534822782082756693",
"3534822775640295278",
"3534822767050374443",
"3534795953569545900",
"3534100162425134878",
"3534099959521478288",
"3533921314651774261",
"3533921242677515410",
"3532568429506599660",
"3532551737116200483",
"3532406793588193293",
"3532387575757013814",
"3532387570581242678",
"3532387562872113857",
"3532387552134695349",
"3532386155389520577",
"3532386128353044669",
"3532384929176356325",
"3532235622414550298",
"3531137472492736673",
"3531137452955666057",
"3531137373708495073",
"3531075714948278995",
"3529232497730659226",
"3529230893350650821",
"3527232223583420408",
"3529230863285890583",
"3529230856843439964",
"3529230850400991192",
"3529230826988383283",
"3529212596789983889",
"3527232247205740010",
"3527232232173352719",
"3526259970678991500",
"3526259942761706710",
"3526259930128463163",
"3526259921538526322",
"3526259912948582837",
"3515672097395314304",
"3514245413924257679",
"3514245407448244254",
"3514236353657176619",
"3514204210121945186",
"3514204197270598773",
"3514204186499623822",
"3514204177943240919",
"3512741955203238358",
"3512720274208335604",
"3512211737598234718",
"3512198439976831003",
"3512899770328821609",
"3512163341906745682",
"3512160115983653011",
"3512159478181013693",
"3531137923464298584",
"3531137914874372321",
"3531137908222204024",
"3531137901779756991",
"3531137893189820103",
"3531137884599893507",
"3531137878367146512",
"3531137869567507571",
"3531137860977567597",
"3531137569129497660",
"3539103233211376339",
"3539103227062525757",
"3539103222473961785",
"3539103218178985215",
"3539103214177616469",
"3539103207735171774",
"3539103203146611056",
"3539103196704157397",
"3539103192702791336",
"3539103188114224285",
"3539102548457690276",
"3539102537720268240",
"3539102531277820438",
"3539102415020111702",
"3539102408577655565",
"3539102391691387509",
"3539102383101455091",
"3539102374511522357",
"3539102370216557917",
"3539102363774091372",
"3539102359185524300",
"3539102353036677483",
"3539102346300623879",
"3539102335563217466",
"3539102329414360571",
"3539102320824426172",
"3539102312234490824",
"3539102305498435346",
"3539102294761015013",
"3539102290466058470",
"3539102264989851768",
"3539102258253793411",
"3539102249663865470",
"3539102243221415708",
"3539102238926441391",
"3539102232777605066",
"3539102228189031910",
"3539102219892695152",
"3539102213156646657",
"3539102207007800220",
"3539102149025731428",
"3539102120814847369",
"3539102114665995441",
"3539102105782468436",
"3531137116010453767",
"3531137109568002729",
"3531137100768350213",
"3531137088093175082",
"3531137074998557611",
"3531137062323367996",
"3531137053733427421",
"3531137044933781302",
"3531137038491321985",
"3531137017226209088",
"3531137008426553085",
"3525184952578616509",
"3525184943325981885",
"3525184936883530941",
"3525184928956296381",
"3525184923998629053",
"3525184913923910845",
"3525184906818759869",
"3525184898228825277",
"3525184805887031309",
"3525184810844694717",
"3525184840246765757",
"3525184847351917757",
"3525184859574124502",
"3525184864531786941",
"3525184888154106045",
"3525184883196439741",
"3525184873121720509",
"3525184797959793853",
"3525184789369859261",
"3522215776784233052",
"3522215864831057436",
"3522215858262780506",
"3522215851946162699",
"3522215845377881743",
"3522215838935422028",
"3522215830471325905",
"3522215824028863914",
"3522215817460593244",
"3522215808870660818",
"3522215800406554765",
"3522215793964101389",
"3522215783100846821",
"3522215765920981066",
"3522215757456868789",
"3522215731561237780",
"3517404197995691914",
"3517404204069042333",
"3522215684316596809",
"3522215690759058012",
"3522215699474820902",
"3522215705791437523",
"3522215725118784310",
"3522215718802176209",
"3522215712359712673",
"3517404191553233433",
"3517404184741684396",
"3517404165783422593",
"3517404158971880289",
"3517404150751037282",
"3517404142161108790",
"3517404133202074637",
"3517404124981235241",
"3517404107801373126",
"3511992848230650059",
"3511992853976856589",
"3512941747191684126",
"3512941755781618747",
"3512941776342104077",
"3512941783698914048",
"3512941791374489809",
"3517404090252398568",
"3517404098842332968",
"3511990841784676488",
"3511990848923384325",
"3511990854669581208",
"3511992806732215785",
"3511992813870919177",
"3511992819617113303",
"3511992824608326454",
"3511992838944465511",
"3511992843239439473",
"3511990240489257395",
"3511990251922923134",
"3511990262660343294",
"3511990272701513264",
"3511990289881368151",
"3511990810268665200",
"3511990818162347284",
"3511990824604798061",
"3511990836038480531",
"3511989256941736445",
"3511989265531672723",
"3511989575465572762",
"3511989583359248926",
"3511989596940408841",
"3511989609825319416",
"3511990188949637433",
"3511990202530796207",
"3511990231899314148",
"3511989234015681507",
"3535354385510968171",
"3532383681488357813",
"3532383672898426731",
"3535354161686133777",
"3532383660894332977",
"3535353904474631282",
"3534104793507183602",
"3532383642833664209",
"3525139416672644285",
"3525139408745409725",
"3534848614272601364",
"3535353621006788657",
"3525139303518710973",
"3525139395197807805",
"3525139292118592701",
"3539247851496284366",
"3525139340025932989",
"3525139378017938621",
"3534104780622272688",
"3525139401640258749",
"3535353348276365964",
"3534104200801685969",
"3525139326478331069",
"3534848055926856580",
"3531137845945175061",
"3532383632096236499",
"3525139269158972605",
"3531137837355245594",
"3525139358690585789",
"3534104190064272135",
"3528345689106949080",
"3534846772645997196",
"3535353077206891153",
"3531137831122503647",
"3531137822322863353",
"3532383624387105747",
"3532383613649697425",
"3534847028196554765",
"3539247842612751055",
"3532383574994987660",
"3531137813732925132",
"3532383604178947348",
"3534102519321995082",
"3531137807500184817",
"3532383593441540109",
"3534103344995899507",
"3528345666424152306",
"3531137798910252301",
"3531137792467798669",
"3532378605717825725",
"3531137751455901537",
"3532378597127884052",
"3531137783877875176",
"3532378613426959388",
"3534846749023668661",
"3534104171777100291",
"3534103375060670276",
"3531137775287940298",
"3531137768635769664",
"3525134507525023933",
"3531137745223164055",
"3512144493031729341",
"3532378585509672973",
"3525136304968838333",
"3528345650452241132",
"3512025306749742113",
"3512025324625865972",
"3512025336814511476",
"3532378577800542417",
"3531137760045838878",
"3534103357880809261",
"3512025331068307117",
"3512144468788652221",
"3531137691536078854",
"3512144481673554109",
"3532378533970057067",
"3525134499597790397",
"3512023008942228477",
"3532378544707471797",
"3534102506437095047",
"3512023015384690202",
"3525136299189087421",
"3532378564915629332",
"3512023022523394625",
"3532378556325692214",
"3532378500491131537",
"3525133651341749437",
"3525131960609418429",
"3525131930544647357",
"3531137682736415161",
"3531137652671651129",
"3525136294231420093",
"3525134473165286589",
"3525131697131629757",
"3531137670061230017",
"3525134480270437565",
"3531137721391129663",
"3531137713010915016",
"3531137702063783436",
"3532378524113442963",
"3525132118038424765",
"3525136287788969149",
"3525133732283428029",
"3525136268461616317",
"3534102494592380366",
"3531137631196822458",
"3525136279861734589",
"3525136260534381757",
"3525133629204212925",
"3525133674964069565",
"3525131913364778173",
"3525136273419283645",
"3525131883300007101",
"3531137661261591018",
"3525134465238052029",
"3531136976424019202",
"3512024243745335231",
"3531137644081715629",
"3512024237999130132",
"3525133682891304125",
"3531137234122049156",
"3528345627769445495",
"3525133739388579005",
"3525133717913742525",
"3531137618311906653",
"3525131973494320317",
"3525131946239732925",
"3525134493155339453",
"3525133689996455101",
"3513296932397121844",
"3531137598984563917",
"3531137225322399878",
"3528345578377328406",
"3531137218879950607",
"3531136969771859770",
"3531137199552603578",
"3528345591262229724",
"3513296916450378399",
"3531136957096658081",
"3531136963329403965",
"3531137193110152634",
"3513296927187808483",
"3531137175930287240",
"3513296855087713607",
"3525131987041922237",
"3513296908774808507",
"3531137184729925620",
"3513296875648189949",
"3531137167550066442",
"3525132002074307773",
"3531137161107607269",
"3525131896847609021",
"3513296869205751380",
"3513296900184881102",
"3531137208142530021",
"3513296894975550530",
"3525134488197672125",
"3513296883005004909",
"3528304696731116357",
"3525133700071173309",
"3525134460943084733",
"3525133725840977085",
"3528304677403767326",
"3525133642089114813",
"3525133659931683005",
"3525132125965659325",
"3528304654989404767",
"3528304774040520635",
"3528304632306607002",
"3528304619421702386",
"3528304395143883844",
"3528304607744768074",
"3528304585061962457",
"3528304550702234701",
"3528304426148183555",
"3528304491780648185",
"3528304533522365436",
"3528304515402966188",
"3528304449770502940",
"3528304468158330180",
];
var study_css = ".egg_study_btn{outline:0;border:0;position:fixed;top:5px;left:5px;padding:12px 20px;border-radius:10px;cursor:pointer;background-color:#fff;color:#d90609;font-size:18px;font-weight:bold;text-align:center;box-shadow:0 0 9px #666777}.egg_manual_btn{transition:0.5s;outline:none;border:none;padding:12px 20px;border-radius:10px;cursor:pointer;background-color:#e3484b;color:rgb(255,255,255);font-size:18px;font-weight:bold;text-align:center;}.egg_auto_btn{transition:0.5s;outline:none;border:none;padding:12px 20px;border-radius:10px;cursor:pointer;background-color:#666777;color:rgb(255,255,255);font-size:18px;font-weight:bold;text-align:center;}.egg_setting_box{position:fixed;top:70px;left:5px;padding:12px 20px;border-radius:10px;background-color:#fff;box-shadow:0 0 9px #666777}.egg_setting_item{margin-top:5px;height:30px;width:140px;font-size:16px;display:flex;justify-items:center;justify-content:space-between}input[type='checkbox'].egg_setting_switch{cursor:pointer;margin:0;outline:0;appearance:none;-webkit-appearance:none;-moz-appearance:none;position:relative;width:40px;height:22px;background:#ccc;border-radius:50px;transition:border-color .3s,background-color .3s}input[type='checkbox'].egg_setting_switch::after{content:'';display:inline-block;width:1rem;height:1rem;border-radius:50%;background:#fff;box-shadow:0,0,2px,#999;transition:.4s;top:3px;position:absolute;left:3px}input[type='checkbox'].egg_setting_switch:checked{background:#fd5052}input[type='checkbox'].egg_setting_switch:checked::after{content:'';position:absolute;left:55%;top:3px}";
GM_addStyle(study_css);
var abc="<div style='position:fixed;z-index:999999;background-color:#ccc;cursor:pointer;top:40%;left:0px;'>"+
"<div id='btn1' class = \"egg_study_btn\">开始学习 </div>"+
"</div>";
$(document).ready(function(){
let url = window.location.href;
console.log(url)
if(url == "https://dywlxy.dtdjzx.gov.cn/personal-center" || url == "https://dywlxy.dtdjzx.gov.cn/dashboard" ){
let ready = setInterval(function() {
if($(".main_main")) {
clearInterval(ready);//停止定时器
//初始化设置
//创建"开始学习"按钮
$("body").append(abc);
}
}, 1000);
}else{
let readyy = setInterval(function() {
if(document.getElementsByTagName("video")[0]) {
//停止定时器
let video = document.getElementsByTagName("video")[0];
video.muted = true;
video.play();
if(document.getElementsByTagName("video")[0].currentTime>1){
clearInterval(readyy);
createTip();//创建窗口关闭提示
console.log(video.currentTime);
reading(1,parseInt(video.duration)-parseInt(video.currentTime)+20);
}
}
}, 1000);
}
});
//等待窗口关闭
function waitingClose(newPage){
return new Promise(resolve => {
let doing = setInterval(function() {
if(newPage.closed) {
clearInterval(doing);//停止定时器
resolve('done');
}
}, 1000);
});
}
//读新闻或者看视频
//type:0为新闻,1为视频
function reading(type,time){
//看文章或者视频
//let video = document.getElementsByTagName("video")[0];
//console.log(video.currentTime);
//let time = parseInt(video.currentTime)+20 ;//**秒后关闭页面
let scrollLength = document.body.scrollHeight/2;
var readingInterval = setInterval(function(){
time--;
$("#studyTip").text(time + " 秒后关闭页面");
let video = document.getElementsByTagName("video")[0]
if(time <= 0||parseInt(video.duration)-parseInt(video.currentTime)==0){
if(type == 0){
GM_setValue('readingUrl',null);
}else{
GM_setValue('watchingUrl',null);
}
clearInterval(readingInterval);
window.close();
}
},1000);
//关闭文章或视频页面
}
//等待时间工具函数
function waitingTime(time){
if(!Number.isInteger(time)){
time = 1000;
}
return new Promise(resolve => {
setTimeout(function(){
resolve('done');
},time);
});
}
//创建学习提示
function createTip(){
let tipInfo = document.createElement("div");
//添加样式
tipInfo.setAttribute("id","studyTip");
tipInfo.innerText = "正在初始化....";
tipInfo.style.position = "fixed";
tipInfo.style.bottom = "15px";
tipInfo.style.left = "5px";
tipInfo.style.padding = "12px 14px";
tipInfo.style.border = "none";
tipInfo.style.borderRadius = "10px";
tipInfo.style.backgroundColor = "#222222";
tipInfo.style.color = "#ffffff";
tipInfo.style.fontSize = "14px";
tipInfo.style.fontWeight = "bold";
//插入节点
let body = document.getElementsByTagName("body")[0];
body.append(tipInfo)
}
function createStartButton(){
let base = document.createElement("div");
var baseInfo="";
baseInfo += "<form id=\"settingData\" class=\"egg_menu\" action=\"\" target=\"_blank\" onsubmit=\"return false\"><div class=\"egg_setting_box\"><div class=\"egg_setting_item\"><label>新闻<\/label><input class=\"egg_setting_switch\" type=\"checkbox\" name=\"0\" " + (settings[0] ? 'checked': '') +"\/> <\/div> <div class=\"egg_setting_item\"> <label>视频<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"1\" " + (settings[1] ? 'checked': '') +"\/> <\/div> <div class=\"egg_setting_item\"> <label>每日答题<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"6\" "+ (settings[6] ? 'checked': '') +"\/> <\/div> <div class=\"egg_setting_item\"> <label>每周答题<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"2\" "+ (settings[2] ? 'checked': '') +"\/> <\/div> <div class=\"egg_setting_item\"> <label>专项练习<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"5\" "+ (settings[5] ? 'checked': '') + "\/><\/div><hr \/><div title='Tip:开始学习后,隐藏相关页面和提示(不隐藏答题中的关闭自动答题按钮)' class=\"egg_setting_item\"> <label>运行隐藏<\/label> <input class=\"egg_setting_switch\" type=\"checkbox\" name=\"7\""+ (settings[7] ? 'checked': '') + "/></div><a style=\"text-decoration: none;\" title=\"视频不自动播放?点此查看解决办法\" target=\"blank\" href=\"https://docs.qq.com/doc/DZllGcGlJUG1qT3Vx\"><div style=\"color:#5F5F5F;font-size:14px;\" class=\"egg_setting_item\"><label style=\"cursor: pointer;\">视频不自动播放?<\/label><\/div><\/a><\/div><\/form>";
base.innerHTML = baseInfo;
let body = document.getElementsByTagName("body")[0];
body.append(base)
let startButton = document.createElement("button");
startButton.setAttribute("id","startButton");
startButton.innerText = "开始学习";
startButton.className = "egg_study_btn egg_menu";
//添加事件监听
try{// Chrome、FireFox、Opera、Safari、IE9.0及其以上版本
startButton.addEventListener("click",start,false);
}catch(e){
try{// IE8.0及其以下版本
startButton.attachEvent('onclick',start);
}catch(e){// 早期浏览器
console.log("开始学习按钮绑定事件失败")
}
}
//插入节点
body.append(startButton)
}
async function watchVideo(){
for(let i =0; i < videos.length; i++){
GM_setValue('watchingUrl',videos[i]);
console.log("正在观看第" + (i+1) + "个视频");
$("#btn1").text("正在观看第" + (i+1)+"/"+videos.length + "个视频");
let newPage = GM_openInTab("https://dywlxy.dtdjzx.gov.cn/course-resources/course/course-detail?id="+videos[i],{active: true,insert: true, setParent :true})
await waitingClose(newPage);
await waitingTime(1500);
}
$("#btn1").text("播放完毕");
window.location.reload();
}
$("body").on("click","#btn1",function(){
watchVideo();
//getVideos();
//getHotVideos();
console.log((new Date).getTime())
})