// ==UserScript==
// @name 灯塔在线
// @namespace **************
// @version 1.01
// @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==
//本脚使用了不学习何以强国的部分代码 侵删
//自定义课程列表 保存课程 看完的视频注意手工删除
var videos = [
"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 + " 秒后关闭页面");
if(time <= 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())
})