// ==UserScript== // @name 阅读模式辅助 // @description 美化滚动条,添加小说目录(仅支持部分网站),配合插件“Circle 阅读模式”使用更棒哦。 // @author little3022 // @namespace little3022.TM.Cataloguer // @homepageURL https://greasyfork.org/users/782903 // @supportURL https://greasyfork.org/scripts/445980/feedback // @version 0.1.2 // @license GNU GPL v2.0 // @run-at document-end // @match *://*/* // @grant GM_setValue // @grant GM_getValue // @grant GM_log // @downloadURL https://update.greasyfork.icu/scripts/445980/%E9%98%85%E8%AF%BB%E6%A8%A1%E5%BC%8F%E8%BE%85%E5%8A%A9.user.js // @updateURL https://update.greasyfork.icu/scripts/445980/%E9%98%85%E8%AF%BB%E6%A8%A1%E5%BC%8F%E8%BE%85%E5%8A%A9.meta.js // ==/UserScript== class Cataloguer { constructor() { this.__name__ = 'Cataloguer'; this.matchRules= [{ host: '', describe: '', }]; this.reHrefs = [ // 章节及小说主页链接(捕获 1 - n 为主页)的正则表达式 /(http\S+www\.biquger\.com\/biquge\/\d+)\/\d+/, /(http\S+www\.ibswtan\.com\/\d+\/\d+)\/\d+\.html/, /(http\S+www\.huaxiaci\.com\/\d+)\/\d+\.html/, /(http\S+www\.xbiquge\.la\/\d+\/\d+)\/\d+\.html/, /(http\S+www\.bswtan\.com\/\d+\/\d+)\/\d+\.html/, /(http\S+www\.360xs\.com\/mulu\/\d+\/\d+)-\d+(\.html)/, /(http\S+www\.biduoxs\.com\/biquge\/\S+\/)\S+\.html/, /(http\S+www\.biqugee\.com\/book\/\d+\/)\d+.html/, /(http\S+www\.bqg99\.cc\/book\/\d+\/)\d+\.html/, /(http\S+www\.ncjy\.net\/bxwx\/\d+\/)\d+\.html/, /(http\S+www\.xxyanqing5\.com\/book\/\d+\/)\d+\.html/, /(http\S+www\.fyrsks\.com\/bqg\/\d+\/)\d+\.html/ ]; this.titleSelectors = [ // 标题选择器 (单一选择器) '#info > h1', 'body > div.container > div.content > div:nth-child(2) > div.bookinfo > h1', '#article_right > div > a > h1', 'body > div.book > div.info > h1', 'body > div.container > div.row.row-detail > div > div > div.info > div.top > h1' ]; this.catalogueSelectors = [ // 目录选择器 (群选择器) '#list > dl > dd > a', '#list-chapterAll > dd > a', '#index_list_li1 > a', 'body > div.listmain > dl > dd > a', 'body > div.container > div.row.row-section > div > div:nth-child(4) > ul > li > a' ]; this.jData = { thisURL: '', homeURL: '', title: '', // 小说标题 total: 0, // 总章节数 active: { index: 0, // 活动章节索引 href: '', text: '', node: null } }; this.sMainElementID = 'OCCataloguer'; this.elCataloguer = null; this.elInfo = null; this.elTitle = null; this.elProgress = null; this.elLastRead = null; this.elList = null; this._first = true; } printLog(info) { Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for(var k in o) { if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); } return fmt; } let date = new Date(); // this._tiper.append(`${date.Format('yyyy-MM-dd hh:mm:ss.S')}: ${info}`); GM_log(`${date.Format('yyyy-MM-dd hh:mm:ss.S')}: ${info}`); } checkURL() { // 检查 URL 是否匹配以判断是否在该网页运行此脚本 for(let re of this.reHrefs) { let match = document.URL.match(re); if(match && match.length >= 2) { this.jData.thisURL = match[0]; for(let i = 1; i < match.length; i++) { this.jData.homeURL += match[i]; } return true; } } return false; } showGUI() { // 显示 GUI let elCataloguer = document.createElement('div'); let elStyle = document.createElement('style'); let elBtShow = document.createElement('div'); let elWrapper = document.createElement('div'); let elTitle = document.createElement('h3'); let elProgress = document.createElement('h5'); let elLastRead = document.createElement('div'); let elList = document.createElement('div'); let elInfo = document.createElement('div'); elCataloguer.id = this.sMainElementID; elBtShow.className = 'OCC-btShow'; elWrapper.className = 'OCC-wrapper'; elLastRead.className = 'OCC-lastread'; elList.className = 'OCC-list'; elInfo.className = 'OCC-info'; elStyle.innerText = '#OCCataloguer .OCC-list::-webkit-scrollbar {width: 8px;background-color: rgba(0, 40, 51, 0.8);}#OCCataloguer .OCC-list::-webkit-scrollbar-thumb {background-color: #bbb5ac;}#OCCataloguer {position: fixed;top: calc(50% - 182.5px);left: -280px;width: 300px;height: 365px;border-radius: 0 8px 8px 0;background-color: rgba(0, 50, 64, 0.8);transition: left 0.2s linear;}#OCCataloguer:hover {left: 0px;}#OCCataloguer:hover .OCC-btShow {display: none;}#OCCataloguer:hover .OCC-wrapper {display: block;}#OCCataloguer .OCC-btShow {position: absolute;right: 0px;width: 20px;height: 100%;border-radius: 0 8px 8px 0;line-height: 360px;text-align: center;vertical-align: middle;color: lightgray;}#OCCataloguer .OCC-wrapper {display: none;}#OCCataloguer h3 {margin: 12px 0 0px 16px;width: 200px;color: #beb9b2;white-space: nowrap;overflow: hidden;cursor: pointer;}#OCCataloguer h3:hover {color: green;}#OCCataloguer h5 {margin: 0 0 0 16px;width: 100px;color: #beb9b2;white-space: nowrap;overflow: hidden;}#OCCataloguer .OCC-lastread {margin: 5px 5px 0 5px;border-bottom: 1px dashed #A7A7A7;height: 24px;}#OCCataloguer .OCC-list {width: 300px;height: 265px;overflow-x: hidden;overflow-y: auto;}#OCCataloguer .OCC-info {width: 300px;height: 100%;font-size: 20px;line-height: 280px;text-align: center;vertical-align: middle;color: #beb9b2;overflow: hidden;white-space: nowrap;}#OCCataloguer dl {margin: 0;padding-top: 5px;}#OCCataloguer dd {margin: 0 5px 0 5px;padding: 0 0 0 16px;border-radius: 3px;width: calc(100% - 30px);height: 24px;vertical-align: middle;overflow: hidden;text-overflow: ellipsis;}#OCCataloguer dd:hover {padding: 0 0 0 20px;background-color: rgba(128, 128, 128, 0.35);box-shadow:0 2px 5px #303030,0 -2px 5px #000;}#OCCataloguer a {display: inline-block;width: 100%;font-size: 13px;line-height: 24px;color: #A7A7A7;text-decoration: none;white-space: nowrap;}#OCCataloguer a:visited {color: #00bbff;}#OCCataloguer #OCC-active {margin: 5px 5px 5px 5px;background-color: rgba(0, 199, 0, 0.3);box-shadow:2px 2px 5px #303030,2px -2px 5px #000;}#OCCataloguer .OCC-lastread a {color: salmon;}#OCCataloguer #OCC-active a {color: #A7A7A7;}'; elBtShow.innerText = '▶'; elTitle.innerText = 'Title'; elProgress.innerText = '(9999/9999)'; elLastRead.innerHTML = '