// ==UserScript==
// @name 学在浙大/智云课堂 辅助脚本
// @description 学在浙大/智云课堂 辅助脚本 by memset0
// @namespace https://github.com/memset0/Learning-at-ZJU-Helper
// @homepage https://github.com/memset0/Learning-at-ZJU-Helper
// @supportURL https://github.com/memset0/Learning-at-ZJU-Helper/issues
// @match *://classroom.zju.edu.cn/*
// @match *://onlineroom.cmc.zju.edu.cn/*
// @match *://livingroom.cmc.zju.edu.cn/*
// @match *://interactivemeta.cmc.zju.edu.cn/*
// @match *://courses.zju.edu.cn/*
// @match **://pintia.cn/*
// @grant unsafeWindow
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addValueChangeListener
// @grant GM_removeValueChangeListener
// @grant GM_getResourceText
// @resource jszip.min.js https://jsd.cdn.zzko.cn/gh/memset0/Learning-at-ZJU-Helper@latest/lib/jszip.min.js
// @encoding utf-8
// @run-at document-start
// @version 1.5.2
// @author memset0
// @license MIT
// ==/UserScript==
(() => {
var e = {
271: (e, t, n) => {
"use strict";
n.d(t, {
A: () => c
});
var r = n(601),
o = n.n(r),
i = n(314),
a = n.n(i)()(o());
a.push([e.id, ".mem-pta-btn{border:none;border-radius:4px}", ""]);
const c = a
},
443: (e, t, n) => {
"use strict";
n.d(t, {
A: () => c
});
var r = n(601),
o = n.n(r),
i = n(314),
a = n.n(i)()(o());
a.push([e.id, ".content-right .mem-bvp-btn{display:none}.mem-bvp-btn{position:relative;margin-right:10px;order:-1;color:#fff;font-size:12px}.mem-bvt-fullscreen .app-wrap{overflow:hidden!important}.mem-bvt-fullscreen .player-wrapper{position:fixed!important;top:0;left:0;z-index:114514!important;width:100%!important;height:100%!important}", ""]);
const c = a
},
297: (e, t, n) => {
"use strict";
n.d(t, {
A: () => c
});
var r = n(601),
o = n.n(r),
i = n(314),
a = n.n(i)()(o());
a.push([e.id, ".mem-btn{border:none;display:flex;margin-left:16px;cursor:pointer;height:32px;line-height:32px;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;border-radius:4px;background-color:#f0f1f3;font-size:14px;color:#144aea;text-align:center;position:relative;padding:0 6px}@media screen and (max-width:1679px){.mem-btn{margin-left:11.42856px;height:22.85712px;line-height:22.85712px;font-size:9.99999px}}@media screen and (min-width:1680px) and (max-width:1919px){.mem-btn{margin-left:14px;height:28px;line-height:28px;font-size:12.25px}}", ""]);
const c = a
},
254: (e, t, n) => {
"use strict";
n.d(t, {
A: () => c
});
var r = n(601),
o = n.n(r),
i = n(314),
a = n.n(i)()(o());
a.push([e.id, ".footer.gtm-category.ng-scope,__nothing__{display:none!important}", ""]);
const c = a
},
844: (e, t, n) => {
"use strict";
n.d(t, {
A: () => c
});
var r = n(601),
o = n.n(r),
i = n(314),
a = n.n(i)()(o());
a.push([e.id, ".custom-footer,.feedback-wrapper,.hot-recommend-wrapper,.menu-content>.first-menu:nth-child(4),.menu-content>.first-menu:nth-child(5),__nothing__{display:none!important}__nothing__{opacity:0!important;pointer-events:none;cursor:default}.living-page-wrapper{padding-bottom:20.040129px}.course-filter-searchAll-custom{border-left:none!important;border-right:none!important}.collect>.collect_span,.collect>.good_span,.operate_wrap>.collect_span,.operate_wrap>.good_span{display:none!important}.side_tab_wrap .side_tab{background:#f9f9f9!important;transform:none!important;color:#a0a0a0!important}.side_tab_wrap .side_tab span{transform:none!important}.side_tab_wrap .side_tab.active span{color:#144aea!important;font-weight:700!important}.relative-info-gap,.relative-info-right{display:none}.relative-info-left{width:100%!important}", ""]);
const c = a
},
428: (e, t, n) => {
"use strict";
n.d(t, {
A: () => c
});
var r = n(601),
o = n.n(r),
i = n(314),
a = n.n(i)()(o());
a.push([e.id, ".ppt_opr_lay>.pip-btn{display:inline-block;vertical-align:middle;margin-left:10px;margin-right:-20px}.pip-btn{position:relative;margin-right:10px;order:2;opacity:.75}.pip-btn>.svg-icon{fill:white;width:24px;height:24px}.pip-btn:hover>.svg-icon{fill:#248ef1}.pip-window .pip-btn{display:none}.pip-window>.ppt_container>.ppt_opr_con{display:none;position:absolute;bottom:0;background:#000;overflow-x:clip}.pip-window>.ppt_container:hover>.ppt_opr_con{display:block}.pip-window .opr_lay{justify-content:start!important}.pip-window .ppt_page_btn{margin-left:30px}.pip-window .el-slider__button-wrapper{cursor:pointer!important}.pip-window .el-slider__button-wrapper>.el-slider__button{cursor:pointer!important}", ""]);
const c = a
},
314: e => {
"use strict";
e.exports = function(e) {
var t = [];
return t.toString = function() {
return this.map((function(t) {
var n = "",
r = void 0 !== t[5];
return t[4] && (n += "@supports (".concat(t[4], ") {")), t[2] && (n += "@media ".concat(t[2], " {")), r && (n += "@layer".concat(t[5].length > 0 ? " ".concat(t[5]) : "", " {")), n += e(t), r && (n += "}"), t[2] && (n += "}"), t[4] && (n += "}"), n
})).join("")
}, t.i = function(e, n, r, o, i) {
"string" == typeof e && (e = [
[null, e, void 0]
]);
var a = {};
if (r)
for (var c = 0; c < this.length; c++) {
var s = this[c][0];
null != s && (a[s] = !0)
}
for (var l = 0; l < e.length; l++) {
var u = [].concat(e[l]);
r && a[u[0]] || (void 0 !== i && (void 0 === u[5] || (u[1] = "@layer".concat(u[5].length > 0 ? " ".concat(u[5]) : "", " {").concat(u[1], "}")), u[5] = i), n && (u[2] ? (u[1] = "@media ".concat(u[2], " {").concat(u[1], "}"), u[2] = n) : u[2] = n), o && (u[4] ? (u[1] = "@supports (".concat(u[4], ") {").concat(u[1], "}"), u[4] = o) : u[4] = "".concat(o)), t.push(u))
}
}, t
}
},
601: e => {
"use strict";
e.exports = function(e) {
return e[1]
}
},
213: function(e, t, n) {
var r, o;
void 0 === (o = "function" == typeof(r = function() {
"use strict";
function t(e, t, n) {
var r = new XMLHttpRequest;
r.open("GET", e), r.responseType = "blob", r.onload = function() {
c(r.response, t, n)
}, r.onerror = function() {
console.error("could not download file")
}, r.send()
}
function r(e) {
var t = new XMLHttpRequest;
t.open("HEAD", e, !1);
try {
t.send()
} catch (e) {}
return 200 <= t.status && 299 >= t.status
}
function o(e) {
try {
e.dispatchEvent(new MouseEvent("click"))
} catch (n) {
var t = document.createEvent("MouseEvents");
t.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), e.dispatchEvent(t)
}
}
var i = "object" == typeof window && window.window === window ? window : "object" == typeof self && self.self === self ? self : "object" == typeof n.g && n.g.global === n.g ? n.g : void 0,
a = i.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent),
c = i.saveAs || ("object" != typeof window || window !== i ? function() {} : "download" in HTMLAnchorElement.prototype && !a ? function(e, n, a) {
var c = i.URL || i.webkitURL,
s = document.createElement("a");
n = n || e.name || "download", s.download = n, s.rel = "noopener", "string" == typeof e ? (s.href = e, s.origin === location.origin ? o(s) : r(s.href) ? t(e, n, a) : o(s, s.target = "_blank")) : (s.href = c.createObjectURL(e), setTimeout((function() {
c.revokeObjectURL(s.href)
}), 4e4), setTimeout((function() {
o(s)
}), 0))
} : "msSaveOrOpenBlob" in navigator ? function(e, n, i) {
if (n = n || e.name || "download", "string" != typeof e) navigator.msSaveOrOpenBlob(function(e, t) {
return void 0 === t ? t = {
autoBom: !1
} : "object" != typeof t && (console.warn("Deprecated: Expected third argument to be a object"), t = {
autoBom: !t
}), t.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type) ? new Blob(["\ufeff", e], {
type: e.type
}) : e
}(e, i), n);
else if (r(e)) t(e, n, i);
else {
var a = document.createElement("a");
a.href = e, a.target = "_blank", setTimeout((function() {
o(a)
}))
}
} : function(e, n, r, o) {
if ((o = o || open("", "_blank")) && (o.document.title = o.document.body.innerText = "downloading..."), "string" == typeof e) return t(e, n, r);
var c = "application/octet-stream" === e.type,
s = /constructor/i.test(i.HTMLElement) || i.safari,
l = /CriOS\/[\d]+/.test(navigator.userAgent);
if ((l || c && s || a) && "undefined" != typeof FileReader) {
var u = new FileReader;
u.onloadend = function() {
var e = u.result;
e = l ? e : e.replace(/^data:[^;]*;/, "data:attachment/file;"), o ? o.location.href = e : location = e, o = null
}, u.readAsDataURL(e)
} else {
var d = i.URL || i.webkitURL,
p = d.createObjectURL(e);
o ? o.location = p : location.href = p, o = null, setTimeout((function() {
d.revokeObjectURL(p)
}), 4e4)
}
});
i.saveAs = c.saveAs = c, e.exports = c
}) ? r.apply(t, []) : r) || (e.exports = o)
},
102: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
default: () => y
});
var r = n(72),
o = n.n(r),
i = n(825),
a = n.n(i),
c = n(659),
s = n.n(c),
l = n(56),
u = n.n(l),
d = n(540),
p = n.n(d),
m = n(113),
f = n.n(m),
g = n(271),
h = {};
h.styleTagTransform = f(), h.setAttributes = u(), h.insert = s().bind(null, "head"), h.domAPI = a(), h.insertStyleElement = p(), o()(g.A, h);
const y = g.A && g.A.locals ? g.A.locals : void 0
},
734: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
default: () => y
});
var r = n(72),
o = n.n(r),
i = n(825),
a = n.n(i),
c = n(659),
s = n.n(c),
l = n(56),
u = n.n(l),
d = n(540),
p = n.n(d),
m = n(113),
f = n.n(m),
g = n(443),
h = {};
h.styleTagTransform = f(), h.setAttributes = u(), h.insert = s().bind(null, "head"), h.domAPI = a(), h.insertStyleElement = p(), o()(g.A, h);
const y = g.A && g.A.locals ? g.A.locals : void 0
},
756: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
default: () => y
});
var r = n(72),
o = n.n(r),
i = n(825),
a = n.n(i),
c = n(659),
s = n.n(c),
l = n(56),
u = n.n(l),
d = n(540),
p = n.n(d),
m = n(113),
f = n.n(m),
g = n(297),
h = {};
h.styleTagTransform = f(), h.setAttributes = u(), h.insert = s().bind(null, "head"), h.domAPI = a(), h.insertStyleElement = p(), o()(g.A, h);
const y = g.A && g.A.locals ? g.A.locals : void 0
},
831: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
default: () => y
});
var r = n(72),
o = n.n(r),
i = n(825),
a = n.n(i),
c = n(659),
s = n.n(c),
l = n(56),
u = n.n(l),
d = n(540),
p = n.n(d),
m = n(113),
f = n.n(m),
g = n(254),
h = {};
h.styleTagTransform = f(), h.setAttributes = u(), h.insert = s().bind(null, "head"), h.domAPI = a(), h.insertStyleElement = p(), o()(g.A, h);
const y = g.A && g.A.locals ? g.A.locals : void 0
},
445: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
default: () => y
});
var r = n(72),
o = n.n(r),
i = n(825),
a = n.n(i),
c = n(659),
s = n.n(c),
l = n(56),
u = n.n(l),
d = n(540),
p = n.n(d),
m = n(113),
f = n.n(m),
g = n(844),
h = {};
h.styleTagTransform = f(), h.setAttributes = u(), h.insert = s().bind(null, "head"), h.domAPI = a(), h.insertStyleElement = p(), o()(g.A, h);
const y = g.A && g.A.locals ? g.A.locals : void 0
},
824: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
default: () => y
});
var r = n(72),
o = n.n(r),
i = n(825),
a = n.n(i),
c = n(659),
s = n.n(c),
l = n(56),
u = n.n(l),
d = n(540),
p = n.n(d),
m = n(113),
f = n.n(m),
g = n(428),
h = {};
h.styleTagTransform = f(), h.setAttributes = u(), h.insert = s().bind(null, "head"), h.domAPI = a(), h.insertStyleElement = p(), o()(g.A, h);
const y = g.A && g.A.locals ? g.A.locals : void 0
},
72: e => {
"use strict";
var t = [];
function n(e) {
for (var n = -1, r = 0; r < t.length; r++)
if (t[r].identifier === e) {
n = r;
break
} return n
}
function r(e, r) {
for (var i = {}, a = [], c = 0; c < e.length; c++) {
var s = e[c],
l = r.base ? s[0] + r.base : s[0],
u = i[l] || 0,
d = "".concat(l, " ").concat(u);
i[l] = u + 1;
var p = n(d),
m = {
css: s[1],
media: s[2],
sourceMap: s[3],
supports: s[4],
layer: s[5]
};
if (-1 !== p) t[p].references++, t[p].updater(m);
else {
var f = o(m, r);
r.byIndex = c, t.splice(c, 0, {
identifier: d,
updater: f,
references: 1
})
}
a.push(d)
}
return a
}
function o(e, t) {
var n = t.domAPI(t);
return n.update(e),
function(t) {
if (t) {
if (t.css === e.css && t.media === e.media && t.sourceMap === e.sourceMap && t.supports === e.supports && t.layer === e.layer) return;
n.update(e = t)
} else n.remove()
}
}
e.exports = function(e, o) {
var i = r(e = e || [], o = o || {});
return function(e) {
e = e || [];
for (var a = 0; a < i.length; a++) {
var c = n(i[a]);
t[c].references--
}
for (var s = r(e, o), l = 0; l < i.length; l++) {
var u = n(i[l]);
0 === t[u].references && (t[u].updater(), t.splice(u, 1))
}
i = s
}
}
},
659: e => {
"use strict";
var t = {};
e.exports = function(e, n) {
var r = function(e) {
if (void 0 === t[e]) {
var n = document.querySelector(e);
if (window.HTMLIFrameElement && n instanceof window.HTMLIFrameElement) try {
n = n.contentDocument.head
} catch (e) {
n = null
}
t[e] = n
}
return t[e]
}(e);
if (!r) throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
r.appendChild(n)
}
},
540: e => {
"use strict";
e.exports = function(e) {
var t = document.createElement("style");
return e.setAttributes(t, e.attributes), e.insert(t, e.options), t
}
},
56: (e, t, n) => {
"use strict";
e.exports = function(e) {
var t = n.nc;
t && e.setAttribute("nonce", t)
}
},
825: e => {
"use strict";
e.exports = function(e) {
if ("undefined" == typeof document) return {
update: function() {},
remove: function() {}
};
var t = e.insertStyleElement(e);
return {
update: function(n) {
! function(e, t, n) {
var r = "";
n.supports && (r += "@supports (".concat(n.supports, ") {")), n.media && (r += "@media ".concat(n.media, " {"));
var o = void 0 !== n.layer;
o && (r += "@layer".concat(n.layer.length > 0 ? " ".concat(n.layer) : "", " {")), r += n.css, o && (r += "}"), n.media && (r += "}"), n.supports && (r += "}");
var i = n.sourceMap;
i && "undefined" != typeof btoa && (r += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i)))), " */")), t.styleTagTransform(r, e, t.options)
}(t, e, n)
},
remove: function() {
! function(e) {
if (null === e.parentNode) return !1;
e.parentNode.removeChild(e)
}(t)
}
}
}
},
113: e => {
"use strict";
e.exports = function(e, t) {
if (t.styleSheet) t.styleSheet.cssText = e;
else {
for (; t.firstChild;) t.removeChild(t.firstChild);
t.appendChild(document.createTextNode(e))
}
}
},
962: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
load: () => c,
name: () => o,
skip: () => a
});
var r = n(99);
const o = "更好的 PTA";
function i() {
return location.href + location.hash
}
function a({
namespace: e
}) {
return "PTA" !== e
}
function c({
logger: e,
clipboard: t
}) {
async function o() {
function n(n) {
const r = document.createElement("button");
return r.classList.add("mem-pta-btn"), r.innerText = "复制文本", r.onclick = () => {
r.innerText = "已复制", setTimeout((() => {
r.innerText = "复制文本"
}), 500);
const o = function(e) {
const t = document.createElement("div");
return t.appendChild(e.cloneNode(!0)),
function e(t) {
for (; t.children.length > 0;) e(t.children[0]);
t.outerHTML = function(e) {
return "LABEL" === e.tagName ? "- " + e.innerHTML + "\n\n" : "pc-text-raw" === e.className ? e.innerHTML + " " : "katex-html" === e.className || "mrow" === e.tagName ? "" : "katex" === e.className ? "$" + e.innerHTML + "$" : "IMG" === e.tagName ? `` : "PRE" === e.tagName ? "```\n" + e.innerHTML + "\n```\n" : "P" === e.tagName ? e.innerHTML + "\n\n" : e.innerHTML
}(t)
}(t.children[0]), t.innerHTML.replace(/\n{2,}/g, "\n\n").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/ /g, " ").replace(/"/g, '"').replace(/'/g, "'")
}(n);
t.copy(o), e.debug("plain text:", o)
}, r
}
Array.from(document.querySelectorAll(".pc-x:not(.mem-pta-rendered)")).filter((t => !!t.id && (e.debug(t.id), t.classList.add("mem-pta-rendered"), function(e) {
e.children[0].children[0].appendChild(n(e.children[1]))
}(t), !0))), Array.from(document.querySelectorAll(".p-4:not(.mem-pta-rendered)")).filter((t => !(!t.children || !t.children.length || "题目描述" != t.children[0].innerText.trim() || (e.debug(t), t.classList.add("mem-pta-rendered"), function(e) {
e.children[0].appendChild(n(e.children[1]))
}(t), 0))))
}
n(102);
let a = 20;
document.addEventListener("click", (e => {
a < 5 && (a = 5)
}), !0), (async () => {
let e = i();
for (;;) await (0, r.y)(100), i() !== e && (e = i(), a = 20), a > 0 && (--a, await o())
})()
}
},
961: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
check: () => c,
load: () => s,
name: () => o,
required: () => i
});
var r = n(99);
const o = "更好的视频播放器",
i = ["builtin-video-pages"];
function a(e) {
const t = e.querySelector(".control-bottom .control-right");
return t && t.children && 0 !== t.children.length ? t : null
}
function c({
document: e
}) {
return !!a(e)
}
async function s({
logger: e,
document: t,
elements: o
}) {
n(734);
const i = a(t),
c = t.createElement("div");
c.className = "mem-bvp-btn", c.innerText = "网页全屏", c.onclick = () => async function() {
t.body.classList.toggle("mem-bvt-fullscreen"), await (0, r.y)(100), o.playerVue.resizePlayer()
}(), i.insertBefore(c, i.firstChild)
}
},
15: (e, t, n) => {
"use strict";
function r(e) {
return e && "__vue__" in e
}
n.r(t), n.d(t, {
check: () => c,
load: () => s,
name: () => o,
skip: () => i
});
const o = "[builtin]视频页面前置";
function i({
env: e
}) {
return !e.isVideoPage
}
function a({
document: e
}) {
const t = e.querySelector(".living-page-wrapper"),
n = e.querySelector("#cmcPlayer_container"),
o = e.querySelector(".living-page-wrapper .operate_wrap");
return r(t) && r(n) && o ? {
course: t,
player: n,
wrapper: o,
courseVue: t.__vue__,
playerVue: n.__vue__
} : null
}
function c({
document: e
}) {
return !!a({
document: e
})
}
function s({
logger: e,
document: t,
extendContext: r
}) {
n(756);
const o = a({
document: t
});
e.debug("视频页面元素:", o), r({
elements: o
});
const i = o.wrapper,
c = t.createElement("div");
c.className = "mem-btn-group", i.insertBefore(c, i.firstChild), e.debug("wrapper", i), r({
addButton: function(n, r, o) {
const i = t.createElement("button");
i.className = "mem-btn mem-btn-primary", i.textContent = r, i.style = "display: inline-block", i.setAttribute("data-key", n), i.onclick = () => {
o({
element: i,
setStatus: t => {
e.debug("(button)" + r, "set status:", t), i.innerText = t ? r + "(" + t + ")" : r
}
})
};
for (const e of c.children)
if (Number(e.getAttribute("data-key")) > n) return c.insertBefore(i, e), i;
return c.appendChild(i), i
}
})
}
},
53: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
check: () => c,
load: () => s,
name: () => o,
required: () => i
});
var r = n(838);
const o = "带时间戳的地址复制(精准空降)",
i = ["builtin-video-pages"];
function a(e) {
const t = e.querySelector(".control-bottom .control-right");
return t && t.children && 0 !== t.children.length ? t : null
}
function c({
document: e
}) {
return !!a(e)
}
async function s({
logger: e,
document: t,
elements: n
}) {
const o = (0, r.mr)(t.location.search) || {};
if (o.ts) try {
e.info("需定位到对应时间戳"), e.log("player", n.playerVue), e.log("playTime", n.playerVue.getPlayTime()), n.playerVue.setPlayerPlayTime(o.ts), e.log("playTime", n.playerVue.getPlayTime())
} catch (t) {
e.error("定位失败", t)
}
const i = a(t),
c = t.createElement("div");
c.className = "mem-bvp-btn", c.innerText = "复制地址(精准空降)", c.onclick = () => async function() {
const e = t.location.origin + t.location.pathname,
o = (0, r.mr)(t.location.search) || {};
o.ts = Math.floor(n.playerVue.getPlayTime());
const i = e + (0, r.wj)(o);
(0, r.lW)(i), (0, r.rG)("复制成功!")
}(), i.insertBefore(c, i.firstChild)
}
},
809: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
check: () => u,
load: () => d,
name: () => a,
options: () => s,
required: () => c
});
var r = n(213),
o = n(99),
i = n(838);
const a = "课件下载",
c = ["builtin-video-pages"],
s = {
"auto-remove": !0
};
function l(e) {
return Array.from(e.courseVue.$data.pptList)
}
function u({
elements: e
}) {
return l(e).length > 0
}
function d({
logger: e,
elements: t,
addButton: n,
loadScript: a
}, c) {
let s = l(t).map((e => ({
...e,
ppt: {
...e.ppt
}
}))).map((e => (e.imgSrc = e.imgSrc.replace("http://", "https://"), e.s_imgSrc = e.s_imgSrc.replace("http://", "https://"), e)));
e.debug(`PPT下载(共${s.length}个):`, s[0]), s = function(e) {
const t = [];
for (let n = 0; n < e.length; n++) n + 1 < e.length && e[n + 1].switchTime === e[n].switchTime || t.push(e[n]);
return t
}(s), e.debug(`删除同一秒内的PPT后(共${s.length}个):`, s[0]), n(1.1, "打包下载", (async ({
setStatus: t
}) => {
t("加载JSZip库"), a("jszip.min.js");
const n = new JSZip;
let i = 0,
c = s.length;
await (0, o.f)(s.map((async (r, o) => {
const a = `ppt-${String(o).padStart(4,"0")}-${r.switchTime.replace(/\:/g,"-")}.jpg`,
s = await fetch(r.imgSrc, {
method: "GET"
}),
l = await s.blob();
e.debug("添加图片", a, l), t(`正在下载(${++i}/${c})`), n.file(a, l, {
binary: !0
})
})), 8), t("生成Zip"), e.debug(n);
const l = await n.generateAsync({
type: "blob"
});
e.debug("完成生成zip", l), t("完成"), (0, r.saveAs)(l, "ppt.zip"), t(null)
})), n(1.2, "导出为PDF", (async ({
setStatus: t
}) => {
let n = "",
r = 0,
a = s.length;
const c = await (0, o.f)(s.map((async (n, o) => {
const i = await fetch(n.imgSrc, {
method: "GET"
});
t(`正在下载(${++r}/${a})`);
const c = await i.blob(),
s = URL.createObjectURL(c);
return e.log(o, s), s
})), 8);
t("生成PDF中");
for (const e of c) n += `<div class="page"><img src="${e}" /></div>`;
await (0, i.jt)({
width: 1280,
height: 720,
margin: 0
}, n), t(null)
}))
}
},
238: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
load: () => i,
name: () => r,
required: () => o
});
const r = "视频链接解析",
o = ["builtin-video-pages"];
function i({
logger: e,
clipboard: t,
elements: n,
addButton: r
}) {
r(2, "解析链接", (({
setStatus: r
}) => {
const o = function() {
try {
return "live" === n.playerVue.liveType ? JSON.parse(n.playerVue.liveUrl.replace("mutli-rate: ", ""))[0].url : document.querySelector("#cmc_player_video").src
} catch (e) {
return null
}
}();
o ? (e.info("视频链接:", o), t.copy(o), r("已拷贝"), setTimeout((() => {
r(null)
}), 500)) : alert("获取视频地址失败,请待播放器完全加载后再试。")
}))
}
},
906: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
check: () => c,
description: () => o,
load: () => s,
name: () => r,
required: () => i,
skip: () => a
});
const r = "示例插件",
o = "这是一个示例插件,他不应该被加载到脚本中。",
i = [];
function a() {
return !1
}
function c() {
return !0
}
function s({
logger: e
}) {
e.debug("示例插件已被加载。")
}
},
928: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
load: () => o,
name: () => r
});
const r = "专注模式";
function o({
logger: e,
namespace: t
}) {
"学在浙大" === t ? n(831) : "智云课堂" === t ? n(445) : e.debug("没有可以加载的样式.")
}
},
469: (e, t, n) => {
"use strict";
n.r(t), n.d(t, {
check: () => d,
load: () => p,
name: () => o,
required: () => i
});
var r = n(99);
const o = "播放器画中画",
i = ["builtin-video-pages"];
function a(e) {
const t = e.querySelector(".control-bottom .control-right");
return t && t.children && 0 !== t.children.length ? t : null
}
function c(e) {
const t = e.querySelector(".opr_lay .ppt_opr_lay");
return t && t.children && 0 !== t.children.length ? t : null
}
function s(e) {
const t = e.querySelector(".change-item");
return t && t.children && 0 !== t.children.length ? t : null
}
function l() {
const e = document.createElement("div");
return e.className = "pip-btn", e.innerHTML = '<svg class="svg-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M38 14H22v12h16V14zm4-8H6c-2.21 0-4 1.79-4 4v28c0 2.21 1.79 3.96 4 3.96h36c2.21 0 4-1.76 4-3.96V10c0-2.21-1.79-4-4-4zm0 32.03H6V9.97h36v28.06z"></path></svg>', e
}
async function u() {
if (documentPictureInPicture.window) return void documentPictureInPicture.window.close();
const e = await documentPictureInPicture.requestWindow({
width: 640,
height: 360
});
return [...document.styleSheets].forEach((t => {
try {
const n = [...t.cssRules].map((e => e.cssText)).join(""),
r = document.createElement("style");
r.textContent = n, e.document.head.appendChild(r)
} catch (n) {
const r = document.createElement("link");
r.rel = "stylesheet", r.type = t.type, r.media = t.media, r.href = t.href, e.document.head.appendChild(r)
}
})), e
}
function d({
document: e
}) {
let t = !1;
return "documentPictureInPicture" in window ? t = !0 : logger.debug("PIP api not supported"), t && !!a(e) && !!c(e) && !!s(e)
}
async function p({
logger: e,
document: t,
elements: o,
addButton: i
}) {
n(824);
const d = a(t),
p = l();
p.onclick = () => {
t.querySelector("#cmc_player_video").requestPictureInPicture()
}, d.insertBefore(p, d.lastChild);
let m = !1,
f = null;
s(t).onclick = async () => {
if (m) return void(m = !1);
m = !0, await (0, r.y)(100);
const e = c(t),
n = l();
n.onclick = async () => {
f = u();
const e = t.querySelector(".main_resize_con .ppt_container").__vue__,
n = t.querySelector("#ppt_canvas");
e.drawImg = function(t) {
var r = e,
o = n,
i = new Image;
i.crossOrigin = "anonymous", i.onload = () => function(e) {
var t = i.width,
n = i.height,
a = e.offsetWidth,
c = e.offsetHeight,
s = o.getContext("2d"),
l = t / n,
u = a / c,
d = 0,
p = 0;
l > u ? p = (c - (n = (t = a) / l)) / 2 : d = (a - (t = (n = c) * l)) / 2, console.log("imgW=", t, "imgH=", n, "imgRatio=", l, "csvRatio=", u, "drawPosY=", p, "drawPosX=", d), o.setAttribute("width", a), o.setAttribute("height", c), s.drawImage(i, d, p, t, n);
var m = s.getImageData(0, 0, a, c);
r.middleAry = [m]
}(o), i.src = t
};
const r = t.querySelector(".el-slider__button-wrapper").__vue__,
o = t.querySelector(".el-slider__button").__vue__;
let i = {};
i.onDragStart = r.onDragStart, r.onDragStart = function() {}, i.onDragging = r.onDragging, r.onDragging = function() {}, i.onDragEnd = r.onDragEnd, r.onDragEnd = function() {}, i.updatePopper = o.updatePopper, o.updatePopper = function() {}, f = await f, s(t).style.display = "none";
const a = t.querySelector(".main_resize_con").firstElementChild;
f.document.body.className = "pip-window", f.document.body.append(a), e.drawImg(e.pptImgSrc), f.addEventListener("pagehide", (n => {
const a = t.querySelector(".main_resize_con"),
c = n.target.body.lastChild;
c && (a.append(c), r.onDragStart = i.onDragStart, r.onDragging = i.onDragging, r.onDragEnd = i.onDragEnd, o.updatePopper = i.updatePopper, e.drawImg = function(e) {
var n = this,
r = t.getElementById("ppt_canvas"),
o = new Image;
o.crossOrigin = "anonymous", o.onload = function() {
var e = o.width,
i = o.height,
a = t.getElementById("ppt").offsetWidth,
c = t.getElementById("ppt").offsetHeight,
s = r.getContext("2d"),
l = e / i,
u = a / c,
d = 0,
p = 0;
l > u ? p = (c - (i = (e = a) / l)) / 2 : d = (a - (e = (i = c) * l)) / 2, console.log("imgW=", e, "imgH=", i, "imgRatio=", l, "csvRatio=", u, "drawPosY=", p, "drawPosX=", d), r.setAttribute("width", a), r.setAttribute("height", c), s.drawImage(o, d, p, e, i);
var m = s.getImageData(0, 0, a, c);
n.middleAry = [m]
}, o.src = e
}, e.drawImg(e.pptImgSrc), s(t).style.display = "block")
}))
}, e.insertBefore(n, null)
}
}
},
342: (e, t, n) => {
var r = {
"./better-pintia/index.js": 962,
"./better-video-player/index.js": 961,
"./builtin-video-pages/index.js": 15,
"./copy-with-timestamp/index.js": 53,
"./download-ppt/index.js": 809,
"./download-video/index.js": 238,
"./example-plugin/index.js": 906,
"./focus-mode/index.js": 928,
"./picture-in-picture/index.js": 469
};
function o(e) {
var t = i(e);
return n(t)
}
function i(e) {
if (!n.o(r, e)) {
var t = new Error("Cannot find module '" + e + "'");
throw t.code = "MODULE_NOT_FOUND", t
}
return r[e]
}
o.keys = function() {
return Object.keys(r)
}, o.resolve = i, e.exports = o, o.id = 342
},
838: (e, t, n) => {
"use strict";
n.d(t, {
jt: () => i,
lW: () => o,
mr: () => a,
rG: () => s,
wj: () => c
});
var r = n(484);
function o(e) {
const t = document.createElement("textarea");
t.style.position = "fixed", t.style.opacity = 0, t.value = e, document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t)
}
async function i(e, t) {
const {
width: n,
height: o,
margin: i
} = e;
t = "<style> /* normalize browsers */ html, body { margin: 0 !important; padding: 0 !important; } </style>" + (t = "<style> /* page settings */ @page { size: " + n + "px " + o + "px; margin: " + i + "px; } </style>" + (t = "<style> div.page { width: " + (n - 2 * i) + "px; height: " + (o - 2 * i) + "px; } </style>" + t));
const {
style: a
} = e;
a && (t += "\n\n\n\x3c!-- additional style --\x3e<style>" + a + "</style>\n\n\n");
const c = new Blob([t], {
type: "text/html;charset=utf-8"
}),
s = URL.createObjectURL(c);
r.Ay.debug("blobUrl:", s);
const l = document.createElement("iframe");
l.style.display = "none", l.src = s, document.body.appendChild(l), l.onload = () => {
setTimeout((() => {
l.focus(), l.contentWindow.print()
}), 1)
}
}
function a(e) {
const t = {};
return e.slice(1).split("&").forEach((e => {
const [n, r] = e.split("=");
t[n] = r
})), t
}
function c(e) {
return "?" + Object.entries(e).map((([e, t]) => `${e}=${t}`)).join("&")
}
function s(e) {
alert(e)
}
},
99: (e, t, n) => {
"use strict";
async function r(e) {
return new Promise((t => setTimeout(t, e)))
}
function o(e, t) {
return new Promise(((n, r) => {
let o = 0,
i = 0,
a = 0,
c = [];
! function s() {
if (console.log("!! ", i, e.length), i >= e.length) n(c);
else
for (; a < e.length && o < t;) {
let t = a;
e[a].then((e => {
o--, i++, c[t] = e, s()
})).catch((e => {
r(e)
})), o++, a++
}
}()
}))
}
n.d(t, {
f: () => o,
y: () => r
})
},
484: (e, t, n) => {
"use strict";
n.d(t, {
Ay: () => o
});
class r {
log(...e) {
console.log(this.prefix, ...e)
}
warn(...e) {
console.warn(this.prefix, ...e)
}
error(...e) {
console.error(this.prefix, ...e)
}
debug(...e) {
console.debug(this.prefix, ...e)
}
info(...e) {
console.info(this.prefix, ...e)
}
extends(e) {
return new r(this.namespace + ":" + e)
}
constructor(e) {
this.namespace = e, this.prefix = "[" + e + "]"
}
}
const o = new r("zju-helper")
}
},
t = {};
function n(r) {
var o = t[r];
if (void 0 !== o) return o.exports;
var i = t[r] = {
id: r,
exports: {}
};
return e[r].call(i.exports, i, i.exports, n), i.exports
}
n.n = e => {
var t = e && e.__esModule ? () => e.default : () => e;
return n.d(t, {
a: t
}), t
}, n.d = (e, t) => {
for (var r in t) n.o(t, r) && !n.o(e, r) && Object.defineProperty(e, r, {
enumerable: !0,
get: t[r]
})
}, n.g = function() {
if ("object" == typeof globalThis) return globalThis;
try {
return this || new Function("return this")()
} catch (e) {
if ("object" == typeof window) return window
}
}(), n.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t), n.r = e => {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
value: "Module"
}), Object.defineProperty(e, "__esModule", {
value: !0
})
}, n.nc = void 0, (() => {
"use strict";
var e = n(484),
t = n(99),
r = n(838);
const o = new class {
getNamespace() {
const e = location.hostname;
return "courses.zju.edu.cn" === e ? "学在浙大" : "classroom.zju.edu.cn" === e || "livingroom.cmc.zju.edu.cn" === e || "onlineroom.cmc.zju.edu.cn" === e || "interactivemeta.cmc.zju.edu.cn" === e ? "智云课堂" : "pintia.cn" === e ? "PTA" : null
}
loadScript(t) {
if (this.loadedScripts.includes(t)) return;
this.loadedScripts.push(t), e.Ay.debug(t, GM_getResourceText);
const n = GM_getResourceText(t);
null === n ? e.Ay.error(`脚本 ${t} 加载失败`) : (e.Ay.debug(n), unsafeWindow.eval(n))
}
constructor() {
this.plugins = {};
const e = n(342);
e.keys().forEach((t => {
const n = t.slice(2, -9);
"example-plugin" !== n && (this.plugins[n] = e(t), this.plugins[n].slug = n)
})), this.loadedScripts = []
}
async load() {
const n = {
namespace: this.getNamespace(),
clipboard: {
copy: r.lW
},
window: unsafeWindow,
document: unsafeWindow.document,
env: {
isVideoPage: "classroom.zju.edu.cn" === location.host && "/livingroom" === location.pathname || !("interactivemeta.cmc.zju.edu.cn" !== location.host || "/" !== location.pathname || !location.hash.startsWith("#/replay?"))
},
loadScript: e => this.loadScript(e),
extendContext: e => {
for (const t in e) Object.keys(n).includes(t) && n[t] instanceof Object ? n[t] = {
...n[t],
...e[t]
} : n[t] = e[t]
}
},
o = () => {
for (const e in this.plugins)
if (!this.plugins[e].loaded) return !1;
return !0
};
e.Ay.debug("开始加载插件", this.plugins);
let i = 0;
do {
for (const t in this.plugins) {
const r = this.plugins[t];
if (!r.loaded) {
if (r.required && r.required instanceof Array && r.required.length > 0) {
let t = "ok";
for (const e of r.required) {
if (this.plugins[e].skipped) {
t = "skip";
break
}
if (!this.plugins[e].loaded) {
t = "wait";
break
}
}
if ("skip" === t) {
r.loaded = !0, r.skipped = !0, e.Ay.debug(`跳过加载 ${r.slug} 插件,因为前置插件被跳过`);
continue
}
if ("wait" === t) continue
}
if (r.skip instanceof Function && await r.skip(n)) {
r.loaded = !0, r.skipped = !0, e.Ay.debug(`跳过加载 ${r.slug} 插件`);
continue
}
if (r.check instanceof Function && !await r.check(n)) continue;
await r.load({
...n,
logger: e.Ay.extends(r.slug)
}), r.loaded = !0
}
}
await (0, t.y)(100)
} while (!o() && ++i < 129);
e.Ay.info("插件加载完成!")
}
safe_load() {
(async () => {
try {
await o.load()
} catch (t) {
throw e.Ay.error(t), t
}
})()
}
};
o.safe_load()
})()
})();