// ==UserScript== // @name Bangumi Bgmlist Integrator // @description 将你的"在看"与 bgmlist.com 的放送数据优雅整合! // @namespace bangumi.scripts.prevails.bgmlistintegrator // @version 1.2.2 // @author "Donuts." // @require https://code.jquery.com/jquery-2.2.4.min.js // @include /^https?:\/\/(bgm\.tv|bangumi\.tv|chii\.in)\/$/ // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @connect bgmlist.com // @grant GM_addStyle // @downloadURL none // ==/UserScript== const addOnSources = { //////////////////////////////////////////////////////////////// // 可自行添加播放源超链接 以京吹2(http://bgm.tv/subject/152091)为例 //////////////////////////////////////////////////////////////// // 152091: [ // "https://www.biliplus.com/video/av6556317/", // "http://www.dilidili.com/anime/euphonium2/", // ], //////////////////////////////////////////////////////////////// }; const TIME_ZONE = 'CN'; // valid value: 'CN', 'JP' // if not login, exit if (!document.getElementById('badgeUserPanel')) { return; } function getOneWeekRange(lastDayDate, endTime = '2359') { const end = new Date(lastDayDate); end.setHours(endTime.substr(0, 2)); end.setMinutes(endTime.substr(2, 2), 59, 999); const begin = new Date(end.getTime()); begin.setTime(begin.getTime() - 1000 * 60 * 60 * 24 * 7 + 1); return [begin, end]; } const now = new Date(); const lastWeekRange = getOneWeekRange(now); const WEEK_DAY = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', ]; const bgmlist = GM_getValue('bgmlist') || {}; class Bangumi { constructor(id, a) { this.id = Number(id); this.bgm = bgmlist[this.id]; this.a = a; if (addOnSources && addOnSources[this.id]) { this.bgm.onAirSite = addOnSources[this.id].concat(this.bgm.onAirSite); } } get$Html() { const $re = $(this.a).clone(); $re.find('img').removeAttr('class'); $re.find('span').remove(); $re.attr('title', this.bgm.titleCN + '\n' + this.bgm.titleJP); $re.data('onAirSite', this.bgm.onAirSite); return $re; } getShowDate() { return new Date(this.bgm.showDate || 0); } getEndDate() { return new Date(this.bgm.endDate || 0xfffffffffffff); } isInRange([begin, end]) { const showBegin = this.getShowDate(); const showEnd = this.getEndDate(); if (showBegin <= begin && showEnd >= end) { return true; } if (begin <= showBegin && showBegin <= end) { return true; } if (begin <= showEnd && showEnd <= end) { return true; } return false; } } const myBangumis = $('#prgSubjectList > [subject_type=2] > .thumbTip') .toArray().map(i => new Bangumi(i.getAttribute('subject_id'), i)).filter(i => i.bgm); $('.tooltip').hide(); $('.week:eq(1)').remove(); for (let i = 1; i < 7; i++) { const day = WEEK_DAY[(now.getDay() - i + 7) % 7]; const html = `
${day}