// ==UserScript== // @name agefans Enhance // @namespace https://github.com/IronKinoko/agefans-enhance // @version 1.5.4 // @description 增强agefans播放功能,实现自动换集、无缝换集、画中画、历史记录、断点续播、显示视频源、获取当前页面全部视频等功能 // @author IronKinoko // @match https://www.agefans.net/* // @match https://www.agefans.net/play/* // @match https://www.agefans.net/detail/* // @match *.yhdm.so/v/* // @resource plyrCSS https://cdn.jsdelivr.net/npm/plyr@3.6.4/dist/plyr.min.css // @require https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js // @require https://cdn.jsdelivr.net/npm/plyr@3.6.4/dist/plyr.min.js // @grant GM_getResourceText // @grant GM_addStyle // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; try { let plyrCSS = GM_getResourceText('plyrCSS') GM_addStyle(plyrCSS) } catch(e) { /* empty */ } })(); (function () { 'use strict'; var e = [], t = []; function n(n, r) { if (n && "undefined" != typeof document) { var a, s = !0 === r.prepend ? "prepend" : "append", d = !0 === r.singleTag, i = "string" == typeof r.container ? document.querySelector(r.container) : document.getElementsByTagName("head")[0]; if (d) { var u = e.indexOf(i); -1 === u && (u = e.push(i) - 1, t[u] = {}), a = t[u] && t[u][s] ? t[u][s] : t[u][s] = c(); } else a = c(); 65279 === n.charCodeAt(0) && (n = n.substring(1)), a.styleSheet ? a.styleSheet.cssText += n : a.appendChild(document.createTextNode(n)); } function c() { var e = document.createElement("style"); if (e.setAttribute("type", "text/css"), r.attributes) for (var t = Object.keys(r.attributes), n = 0; n < t.length; n++) e.setAttribute(t[n], r.attributes[t[n]]); var a = "prepend" === s ? "afterbegin" : "beforeend"; return i.insertAdjacentElement(a, e), e; } } var css$4 = ".agefans-wrapper .nav_button {\n cursor: pointer;\n}"; n(css$4,{}); function renderHistroyStyle() { // add a tag visited style let styleDom = document.createElement('style'); styleDom.innerHTML = `.movurl li a:visited { color: red; }`; document.head.appendChild(styleDom); } function detailModule() { renderHistroyStyle(); } var css$3 = ".agefans-wrapper #history {\n background: #202020;\n border: 4px solid #303030;\n}\n.agefans-wrapper #history .history-list {\n padding: 16px;\n display: flex;\n flex-wrap: wrap;\n}\n.agefans-wrapper #history .history-item {\n width: 115px;\n display: inline-block;\n margin: 4px;\n}\n.agefans-wrapper #history .history-item img {\n width: 100%;\n border-radius: 2px;\n}\n.agefans-wrapper #history .history-item .desc .title {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n font-size: 14px;\n margin: 4px 0;\n}\n.agefans-wrapper #history .history-item .desc .position {\n font-size: 14px;\n}"; n(css$3,{}); class History { constructor() { this.cacheKey = 'v-his'; } get his() { return JSON.parse(localStorage.getItem(this.cacheKey) || '[]'); } set his(value) { if (Array.isArray(value)) { localStorage.setItem(this.cacheKey, JSON.stringify(value.slice(0, 100))); } } getAll() { return this.his; } get(id) { return this.his.find(o => o.id === id); } setTime(id, time = 0) { const his = this.his; his.find(o => o.id === id).time = time; this.his = his; } log(item) { const his = this.his; his.unshift(item); this.his = his; } refresh(id, data) { const his = this.his; const index = his.findIndex(o => o.id === id); const item = his.splice(index, 1)[0]; his.unshift(data || item); this.his = his; } has(id) { return Boolean(this.his.find(o => o.id === id)); } logHistory() { var _location$pathname$ma; const id = (_location$pathname$ma = location.pathname.match(/\/play\/(\d*)/)) === null || _location$pathname$ma === void 0 ? void 0 : _location$pathname$ma[1]; if (!id) return; const hisItem = {}; hisItem.id = id; hisItem.title = $('#detailname a').text(); hisItem.href = location.href; hisItem.section = $('li a[style*="color: rgb(238, 0, 0);"]').text(); hisItem.time = 0; hisItem.logo = $('#play_poster_img').attr('src'); if (this.has(id)) { const oldItem = this.get(id); if (oldItem.href !== hisItem.href) { this.refresh(id, hisItem); } else { this.refresh(id); } } else { this.log(hisItem); } } } const his = new History(); function parseTime(time = 0) { return `${Math.floor(time / 60).toString().padStart(2, '0')}:${(time % 60).toString().padStart(2, '0')}`; } function renderHistoryList() { $('#history').html('').append(() => { /** @type {any[]} */ const histories = his.getAll(); let html = ''; histories.forEach(o => { html += ` ${o.title}
${o.title}
${o.section} ${parseTime(o.time)}
`; }); return `
${html || '
暂无数据
'}
`; }); } function renderHistoryPage() { const currentDom = $('.nav_button_current'); $('
').insertBefore('#footer').hide(); $(`历史`).appendTo('#nav').on('click', e => { if ($('#history').is(':visible')) { $('#container').show(); $('#history').hide(); changeActive(currentDom); } else { renderHistoryList(); $('#container').hide(); $('#history').show(); changeActive($(e.currentTarget)); } }); $('.nav_button_current').on('click', e => { $('#container').show(); $('#history').hide(); changeActive(e.currentTarget); }).removeAttr('href'); } function changeActive(dom) { $('.nav_button_current').removeClass('nav_button_current'); $(dom).addClass('nav_button_current'); } function historyModule() { renderHistoryPage(); renderHistoryList(); } function copyToClipboard(element) { var $temp = $("