// ==UserScript== // @name 动漫之家 // @namespace http://tampermonkey.net/ // @version 2024-02-16 // @description try to take over the world! // @author You // @match https://manhua.idmzj.com/* // @match https://www.idmzj.com/ // @icon https://www.google.com/s2/favicons?sz=64&domain=idmzj.com // @resource animate_css https://cdn.jsdelivr.net/npm/animate.css@4.1.1/animate.min.css // @resource element_css https://unpkg.com/element-ui@2.15.0/lib/theme-chalk/index.css // @require https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js // @require https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js // @require https://cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.js // @require https://cdn.jsdelivr.net/npm/jquery_lazyload@1.9.3/jquery.lazyload.min.js // @require https://unpkg.com/element-ui@2.15.0/lib/index.js // @run-at document-start // @license GNU General Public License v3.0 or later // @grant GM_getResourceText // @grant GM_xmlhttpRequest // @grant GM_addStyle // @grant unsafeWindow // @require https://scriptcat.org/lib/513/2.0.0/ElementGetter.js // ==/UserScript== // 跳转到日漫页面 if (window.location.href == 'https://www.idmzj.com/') { window.location.href = 'https://manhua.idmzj.com/' } //删除柯南二维码 GM_addStyle('img[src="https://static.dmzj.com/public/images/app_tro_manhua.jpg"] { visibility: hidden !important; }'); GM_addStyle('a[href="http://www.dmzj.com/app/pc.html"] { pointer-events: none !important; cursor: default !important; }'); //去广告 var ad_list = ["#index_ad", "#ad_iphone", "#ad_code_close", "#ads_right", "#adpc", "#float_code", "#left_ads", "#top_ads", "#ads-manhuaright", "#ads-manhua", "#top_ad", "#conf_ad", ".header-box", "#focus"]; for (var i = 0; i < ad_list.length; i++) { GM_addStyle(ad_list[i] + " {display:none !important;}"); } //日间模式 GM_addStyle(".mainNav,.header-box,.display_graybg,body,.dark_mode .newbody{background:#edecea !important;}") //夜间模式 GM_addStyle(".dark_mode .mainNav,.dark_mode .header-box,.dark_mode .display_graybg,.dark_mode body,.dark_mode .newbody{background:#212121 !important;}") //漫画双叶排布 GM_addStyle('.page_double .scrollbar-demo-item{justify-content:center;flex-direction: row-reverse;display: flex;flex-wrap: wrap;}') GM_addStyle('.page_double .scrollbar-demo-item img{height:100vh !important;}') elmGetter.each('.redhotl#prev_chapter', document, () => { var link = document.querySelector('.redhotl#prev_chapter'); if (link) { link.removeEventListener('click', caidan1); link.addEventListener('click', function () { $('html').removeClass('dark_mode') $('#info').remove() $('#sidebar').remove() }) } }); var uidNumber = localStorage.getItem("uidNumber"); elmGetter.each('.r1', document, () => { // 获取漫画名称+uid+comic_py+url var linkElements = document.getElementsByClassName("btn2"); if (linkElements.length > 0) { var linkElement = linkElements[0]; var href = linkElement.getAttribute('href'); var text = href.split('/')[1]; } var uidElement = $('p[data-v-687068a4].r1'); var hrefAttributeValue = uidElement.find('a[data-v-687068a4]').attr('href'); var uidNumber = hrefAttributeValue.match(/hisUid=(\d+)/); localStorage.setItem("uidNumber",uidNumber) var all_url = `https://manhua.idmzj.com/api/v1/comic2/comic/detail?uid=${uidNumber[1]}&comic_py=${text}`; mulu(all_url) }) elmGetter.each('.scrollbar-demo-item', document, () => { // 删除图片链接 var links = document.querySelectorAll('a[id]'); links.forEach(function (link) { link.removeAttribute("href"); }) var length = document.querySelector('.scrollbar-demo-item').querySelectorAll('a').length; caidan1(length) }); elmGetter.each('.cartoon_online_border', document, reply => { var links = document.querySelectorAll('.cartoon_online_border a'); links.forEach(function (link) { link.addEventListener('click', function () { $('html').addClass('dark_mode'); }); }); }); if (location.href.search(/\/\d+\.shtml/) >= 0) { $('html').addClass('dark_mode'); window.onload = function () { // 删除尾页白和其他 var div1 = document.getElementsByClassName("login_tip in"); if (div1.length > 0) { div1[0].remove(); } var div0 = document.querySelector(".hotrm_list") div0.remove(); var div2 = document.getElementsByClassName('div[position="absolute"][z-index="1"]'); if (div2.length > 0) { div2[0].remove(); } var div3 = document.getElementsByClassName("hotrmbox"); if (div3.length > 0) { div3[0].remove() } //预加载图片 $('img').lazyload(); } } if ($.cookie('dark_mode') === undefined) { $.cookie('dark_mode', true, { expires: 999999, path: '/' }); } if ($.cookie('page_double') === undefined) { $.cookie('page_double', true, { expires: 999999, path: '/' }); } if ($.cookie('fullscreen') === undefined) { $.cookie('fullscreen', true, { expires: 999999, path: '/' }) } if ($.cookie('fanyemodeval') === undefined) { $.cookie('fanyemodeval', 2, { expires: 999999, path: '/' }) } function caidan1(length) { //读取cookie var dark_mode = $.cookie('dark_mode') == 'true'; var page_double = $.cookie('page_double') == 'true'; var fullscreen = $.cookie('fullscreen') == 'false'; var fanye = $.cookie('fanyemodeval') == '2' //翻页模式 if (fanye) { $.cookie('fanyemodeval', 2, { expires: 999999, path: '/' }); } else { $.cookie('fanyemodeval', 1, { expires: 999999, path: '/' }); $('#info').remove() } if (fullscreen) { document.documentElement.requestFullscreen(),fullscreen = false } //暗夜模式 if (dark_mode) { $('html').addClass('dark_mode'); } else { $('html').removeClass('dark_mode'); } //双页显示 if (page_double) { $('html').addClass('page_double'); } else { $('html').removeClass('page_double'); } //获取当前页码 var imgs = $(".scrollbar-demo-item a img"); var last_img = imgs[length - 1] window.addEventListener('wheel', ID) function ID() { imgs.each(function (i, img) { // 判断鼠标位置是否在当前图片区域内 if (window.pageYOffset > img.offsetTop - 5 && window.pageYOffset < img.offsetTop + img.offsetHeight) { info_app.img_id = i + 1; if (pageYOffset > last_img.offsetTop + last_img.offsetHeight - 5) { info_app.img_id = length; } } }); }; setInterval(ID, 100); let info = `
`; let $info = $(info); $("body").append($info); let info_style = ` #info { bottom: 2%; right: 2%; padding: 5px 5px; background: rgba(48,48,48,.7) !important; position: fixed; color: rgba(255,255,255,.7); border-radius: 3px; z-index:99999; } .info_item{ padding:5px 0px; width:120px; cursor: pointer; }`; GM_addStyle(info_style); var info_app = new Vue({ el: '#info', data: { fanye: fanye, full: fullscreen, dark: dark_mode, page: page_double, show: 0, img_id: 1, img_id_all: length, full: 0, }, computed: { message_fanye: function () { return this.fanye ? '↔左右翻页' : '↕上下翻页' }, message_full: function () { return this.full ? '🔒退出全屏' : '🔓进入全屏' }, message_mulu: function () { return ("📖返回目录") }, message_switch: function () { return this.dark ? '☀️日间模式' : '🌙夜间模式' }, message_page: function () { return this.page ? '1️⃣单页排布' : '2️⃣双页排布' }, message_count: function () { return this.img_id + '/' + length }, }, methods: { switch_fanye: function () { this.fanye = !this.fanye if (this.fanye) { $.cookie('fanyemodeval', 2, { expires: 999999, path: '/' }); location.reload(); } else { location.reload(); $('#info').remove() $.cookie('fanyemodeval', 1, { expires: 999999, path: '/' }); } } , switch_full: function () { this.full = !this.full; if (this.full) { document.documentElement.requestFullscreen(); } else { document.exitFullscreen(); } } , switch_mulu: function () { window.location.href = 'https://manhua.idmzj.com' + $(".btn2").attr("href"); }, switch_night: function () { this.dark = !this.dark $.cookie('dark_mode', this.dark, { expires: 999999, path: '/' }); if (this.dark) { $('html').addClass('dark_mode'); } else { $('html').removeClass('dark_mode'); } }, switch_page: function () { this.page = !this.page $.cookie('page_double', this.page, { expires: 999999, path: '/' }); if (this.page) { $('html').addClass('page_double'); } else { $('html').removeClass('page_double'); } }, } }) } function mulu(all_url) { //修改element-ui样式 GM_addStyle('.el-menu{border-right:0px !important;}') GM_addStyle('.el-drawer__wrapper{width:20%;}') GM_addStyle('.el-drawer{background:transparent !important;}') GM_addStyle('.el-drawer__body{background:rgba(0,0,0,.8) !important;overflow-y: auto}') const animate_css = GM_getResourceText("animate_css"); const element_css = GM_getResourceText("element_css"); GM_addStyle(animate_css); GM_addStyle(element_css); GM_addStyle(':root{--animate-duration:500ms;}'); let ch_id = 0; var items = []; //修改滚动条样式 GM_addStyle('::-webkit-scrollbar {width: 4px;height: 0px;}') GM_addStyle('::-webkit-scrollbar-thumb {background-color: rgb(48,48,48);border-radius: 2px;}') // 添加侧边目录栏 let sidebar = ` `; let $sidebar = $(sidebar); $("body").append($sidebar); var sidebar_app = new Vue({ el: '#sidebar', data: { drawer: false, size: '100%', modal: false, direction: 'ltr', items: items, select: -1, index: 0 }, methods: { handleSelect(key) { var selectedChapter = this.items[key]; var chapterLink = document.querySelector(".btn2").href + selectedChapter.id + '.shtml#1'; location.href = chapterLink; this.select = key; GM_addStyle('.el-menu>li:nth-child(' + (parseInt(this.select) + 1) + '){background:rgba(255,165,0,.5) !important}'); }, handleOpen() { var index = this.index; setTimeout(function () { $('.el-drawer__body').animate({ scrollTop: 0 }, 0); $('.el-drawer__body').animate({ scrollTop: $('.el-menu>li:nth-child(' + (index - 1) + ')').offset().top - $('.el-drawer__body').offset().top }, 0); }, 0) }, }, }); // 加载目录 $.ajax({ url: all_url, headers: { "User-Agent": navigator.userAgent }, success: function (data) { var chapterList = data.data.comicInfo.chapterList; chapterList.forEach(function (chapter) { chapter.data.forEach(function (chapterData) { items.unshift({ title: chapterData.chapter_title, id: chapterData.chapter_id, }); const url = location.href; const match = url.match(/\/(\d+)\.shtml/); if (match && match[1]) { const number = match[1]; var index = items.findIndex(item => item.id == number); if (index != -1) { sidebar_app.index = index; for (let i = 1; i <= items.length; i++) { GM_addStyle('.el-menu>li:nth-child(' + i + '){background:transparent !important}'); } GM_addStyle('.el-menu>li:nth-child(' + (index + 1) + '){background:rgba(255,165,0,.5) !important}'); } } } ); }); }, }); } //检测漫画是否屏蔽 function look(){ var titles = []; console.log(titles) var links = document.querySelectorAll(".pictextst"); links.forEach(function(link) { titles.push(link.textContent); }); var links1 = document.querySelectorAll(".picborder a"); console.log(links1.length) links1.forEach((link1) => { var text = link1.getAttribute("href").split("/"); console.log(text) var look_url = `https://manhua.idmzj.com/api/v1/comic2/comic/detail?uid=114835565&comic_py=${text[1]}`; console.log(look_url) // 发起异步请求 fetch(look_url) .then((response) => response.json()) .then((jsonData) => { var list = jsonData.data.comicInfo; if (list.chapterList === null) { // 找到匹配的标题索引 var index = titles.findIndex(title => title === list.title); if (index !== -1) { add_txt(index); // 添加标记 } } }); }); } look() function add_txt(index) { var element = document.querySelectorAll(".numfont")[index]; if (!element.nextSibling) { var span = document.createElement("span"); span.appendChild(document.createTextNode("已被屏蔽")); span.className = "add_txt"; span.style.textAlign = "right"; span.style.marginRight = "60px"; span.style.color = "#ff0000d6"; element.parentNode.insertBefore(span, element.nextSibling); } } elmGetter.each(".mhupdate", document, () => { setInterval(look, 1000); });