☄️动漫之家增强☄️

动漫之家去广告🚫,对日漫版漫画页进行增强:并排布局📖、图片高度自适应↕️、辅助翻页↔️、页码显示⏱、侧边目录栏📑、暗夜模式🌙,请设置即时注入模式以避免页面闪烁⚠️

安裝腳本?
作者推薦腳本

您可能也會喜歡 ☄️拷贝漫画增强☄️

安裝腳本
  1. // ==UserScript==
  2. // @name ☄️动漫之家增强☄️
  3. // @namespace http://tampermonkey.net/
  4. // @version 4.5
  5. // @description 动漫之家去广告🚫,对日漫版漫画页进行增强:并排布局📖、图片高度自适应↕️、辅助翻页↔️、页码显示⏱、侧边目录栏📑、暗夜模式🌙,请设置即时注入模式以避免页面闪烁⚠️
  6. // @author Byaidu
  7. // @match *://*.dmzj.com/*
  8. // @match *://*.dmzj1.com/*
  9. // @license GNU General Public License v3.0 or later
  10. // @resource animate_css https://cdn.jsdelivr.net/npm/animate.css@4.1.1/animate.min.css
  11. // @resource element_css https://unpkg.com/element-ui@2.15.0/lib/theme-chalk/index.css
  12. // @require https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js
  13. // @require https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js
  14. // @require https://cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.js
  15. // @require https://cdn.jsdelivr.net/npm/jquery_lazyload@1.9.3/jquery.lazyload.min.js
  16. // @require https://unpkg.com/element-ui@2.15.0/lib/index.js
  17. // @grant GM_addStyle
  18. // @grant GM_getResourceText
  19. // @grant GM_xmlhttpRequest
  20. // @run-at document-start
  21. // ==/UserScript==
  22.  
  23. (function() {
  24. 'use strict';
  25. //去广告
  26. GM_addStyle('*[style*="2147"]{display:none !important;}')
  27. GM_addStyle('*[style*="hidden;border"]{display:none !important;}')
  28. GM_addStyle('*[style*="width:960px;height:180px"]{display:none !important;}')
  29. GM_addStyle('.ad_bottom_code{display:none !important;}')
  30. GM_addStyle('.ad{display:none !important;}')
  31. GM_addStyle('#app_manhua{display:none !important;}')
  32. //去二维码
  33. GM_addStyle('.footer{display:none !important;}')
  34. GM_addStyle('.foot{display:none !important;}')
  35. GM_addStyle('.float_code{display:none !important;}')
  36. //漫画页检测
  37. if(location.href.search(/\/\d+\.shtml/)>=0){
  38. //切换到上下滚动阅读
  39. if($.cookie('display_mode')==0){
  40. $.cookie('display_mode',1,{expires:999999,path:'/'});
  41. location.reload();
  42. }
  43. //修改滚动条样式
  44. GM_addStyle('::-webkit-scrollbar {width: 4px;height: 0px;}')
  45. GM_addStyle('::-webkit-scrollbar-thumb {background-color: rgb(48,48,48);border-radius: 2px;}')
  46. //修改element-ui样式
  47. GM_addStyle('.el-menu{border-right:0px !important;}')
  48. GM_addStyle('.el-drawer__wrapper{width:20%;}')
  49. GM_addStyle('.el-drawer{background:transparent !important;}')
  50. GM_addStyle('.el-drawer__body{background:rgba(0,0,0,.8) !important;overflow-y: auto}')
  51. //去除图片边框
  52. GM_addStyle('#center_box img{border:0px !important;padding:0px !important;}')
  53. //漫画双页排布
  54. GM_addStyle('.page_double #center_box{justify-content:center;flex-direction: row-reverse;display: flex;flex-wrap: wrap;}')
  55. GM_addStyle('.page_double #center_box img{height:100vh !important;}')
  56. //漫画上下间隔缩小
  57. GM_addStyle('.inner_img{margin-top:0px !important;user-select: none;}')
  58. GM_addStyle('.curr_page{padding:15px;height:unset !important;line-height:unset !important;}')
  59. //修改配色方案
  60. GM_addStyle('.r1{color:#4d4d4d !important;}')
  61. GM_addStyle('.hotrm_about{color:#4d4d4d !important;}')
  62. GM_addStyle('*[style*="display:inline;float:left"]{color:#4d4d4d !important;}')
  63. GM_addStyle('*[style*="display:inline;float:right"]{display:none !important;}')
  64. //去除图片点击样式
  65. GM_addStyle('.inner_img a{cursor:auto !important;}')
  66. //引入css
  67. const animate_css = GM_getResourceText("animate_css");
  68. const element_css = GM_getResourceText("element_css");
  69. GM_addStyle(animate_css);
  70. GM_addStyle(element_css);
  71. GM_addStyle(':root{--animate-duration:500ms;}')
  72. //隐藏顶栏
  73. GM_addStyle(".header-box,.funcdiv{display:none !important;}")
  74. //更改跨页
  75. GM_addStyle('.skip{display:none !important;}')
  76. //日间模式
  77. GM_addStyle(".mainNav,.header-box,.display_graybg,body{background:#edecea !important;}")
  78. //夜间模式
  79. GM_addStyle(".dark_mode .mainNav,.dark_mode .header-box,.dark_mode .display_graybg,.dark_mode body{background:#212121 !important;}")
  80. //读取cookie
  81. if ($.cookie('dark_mode') === undefined) { $.cookie('dark_mode',true,{expires:999999,path:'/'}); }
  82. if ($.cookie('page_double') === undefined) { $.cookie('page_double',true,{expires:999999,path:'/'}); }
  83. var dark_mode = $.cookie('dark_mode')=='true';
  84. var page_double = $.cookie('page_double')=='true';
  85. //暗夜模式
  86. if (dark_mode){
  87. $('html').addClass('dark_mode');
  88. }else{
  89. $('html').removeClass('dark_mode');
  90. }
  91. //双页显示
  92. if (page_double){
  93. $('html').addClass('page_double');
  94. }else{
  95. $('html').removeClass('page_double');
  96. }
  97. let img_id=0;
  98. let id_lock=0;
  99. let middle=0;
  100. let ch_id=0;
  101. let items=[];
  102. //延迟加载
  103. $(function delay(){
  104. //计算页数
  105. if (typeof(g_max_pic_count)=='undefined'){
  106. let parse=JSON.parse;
  107. JSON.parse=function(res){
  108. let ret=parse(res);
  109. if (ret.chapters!==undefined){
  110. ret.chapters[0].data.reverse();
  111. ret.chapters[0].data.forEach(function(item,index){
  112. if (location.href.indexOf('https://manhua.dmzj.com/'+ret.comic_py+'/'+item.chapter_id+'.shtml?cid='+ret.id)>=0){
  113. ch_id=index;
  114. }
  115. items.push({
  116. title:item.chapter_title,
  117. href:'https://manhua.dmzj.com/'+ret.comic_py+'/'+item.chapter_id+'.shtml?cid='+ret.id,
  118. })
  119. })
  120. }
  121. return ret
  122. };
  123. setTimeout(function(){
  124. window.g_max_pic_count=$('.inner_img').length;
  125. delay();
  126. GM_addStyle('.el-menu>li:nth-child('+(ch_id+1)+'){background:rgba(255,165,0,.5) !important}')
  127. },1000)
  128. return;
  129. }
  130. //添加右下角菜单
  131. let info = `
  132. <div id="info" @mouseover="show=1" @mouseleave="show=0">
  133. <transition name="custom-classes-transition" enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__fadeOut">
  134. <template v-if="show"><div id="info_page" class="info_item" @click="switch_page" style="cursor:pointer;">{{message_page}}</div></template></transition>
  135. <transition name="custom-classes-transition" enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__fadeOut">
  136. <template v-if="show"><div id="info_skip" class="info_item" @click="switch_skip" style="cursor:pointer;">{{message_skip}}</div></template></transition>
  137. <transition name="custom-classes-transition" enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__fadeOut">
  138. <template v-if="show"><div id="info_switch" class="info_item" @click="switch_night" style="cursor:pointer;">{{message_switch}}</div></template></transition>
  139. <template><div id="info_count" class="info_item">{{message_count}}</div></template>
  140. </div>`;
  141. let $info = $(info);
  142. $("body").append($info);
  143. let info_style = `
  144. #info {
  145. bottom: 2%;
  146. right: 2%;
  147. padding: 5px 5px;
  148. background: rgba(48,48,48,.7) !important;
  149. position: fixed;
  150. color: rgba(255,255,255,.7);
  151. border-radius: 3px;
  152. }
  153. .info_item{
  154. padding:5px 0px;
  155. width:120px;
  156. }`;
  157. GM_addStyle(info_style);
  158. //vue绑定右下角菜单
  159. var info_app = new Vue({
  160. el: '#info',
  161. data: {
  162. dark:dark_mode,
  163. page:page_double,
  164. show:0,
  165. img_id:0,
  166. skip:0,
  167. },
  168. computed: {
  169. message_switch: function () {
  170. return this.dark?'☀️日间模式':'🌙夜间模式'
  171. },
  172. message_page: function () {
  173. return this.page?'1️⃣单页排布':'2️⃣双页排布'
  174. },
  175. message_skip: function () {
  176. return '📖更改跨页'
  177. },
  178. message_count: function () {
  179. return this.img_id+'/'+g_max_pic_count
  180. }
  181. },
  182. methods:{
  183. switch_night: function(){
  184. this.dark=!this.dark
  185. $.cookie('dark_mode',this.dark,{expires:999999,path:'/'});
  186. if (this.dark){
  187. $('html').addClass('dark_mode');
  188. }else{
  189. $('html').removeClass('dark_mode');
  190. }
  191. },
  192. switch_skip: function(){
  193. this.skip=!this.skip
  194. if (this.skip){
  195. $("#center_box>div:first-child").addClass('skip');
  196. }else{
  197. $("#center_box>div:first-child").removeClass('skip');
  198. }
  199. },
  200. switch_page: function(){
  201. this.page=!this.page
  202. $.cookie('page_double',this.page,{expires:999999,path:'/'});
  203. if (this.page){
  204. $('html').addClass('page_double');
  205. }else{
  206. $('html').removeClass('page_double');
  207. }
  208. $("html").animate({scrollTop: $("#img_"+img_id).offset().top}, 0);
  209. },
  210. }
  211. })
  212. //添加侧边目录栏
  213. let sidebar=`
  214. <div id="sidebar" @mouseleave="drawer=false">
  215. <div id="toggle" @mouseover="drawer=true" style="top:0px;left:0px;height:100vh;width:20vw;position: fixed;"></div>
  216. <el-drawer
  217. title="我是标题"
  218. :size="size"
  219. :modal="modal"
  220. :visible="drawer"
  221. :with-header="false"
  222. :direction="direction"
  223. @open="handleOpen">
  224. <el-menu background-color="transparent"
  225. text-color="#fff"
  226. active-text-color="#ffd04b"
  227. @select="handleSelect">
  228. <template v-for="(item, index) in items">
  229. <el-menu-item v-bind:index="index">{{item.title}}</el-menu-item>
  230. </template>
  231. </el-menu>
  232. </el-drawer>
  233. </div>`
  234. let $sidebar = $(sidebar);
  235. $("body").append($sidebar);
  236. //vue绑定侧边目录栏
  237. var sidebar_app = new Vue({
  238. el: '#sidebar',
  239. data: {
  240. drawer: false,
  241. size:'100%',
  242. modal:false,
  243. direction: 'ltr',
  244. items: items,
  245. },
  246. methods:{
  247. handleSelect(key) {
  248. location.href=this.items[key].href;
  249. },
  250. handleOpen() {
  251. setTimeout(function(){
  252. $('.el-drawer__body').animate({scrollTop:0}, 0);
  253. $('.el-drawer__body').animate({scrollTop:$('.el-menu>li:nth-child('+(ch_id-1)+')').offset().top-$('.el-drawer__body').offset().top}, 0);
  254. },0)
  255. },
  256. }
  257. })
  258. //加载目录
  259. GM_xmlhttpRequest({
  260. method: "GET",
  261. headers: {"User-Agent": navigator.userAgent},
  262. url: $('.btn2').attr('href'),
  263. onload: (res) => {
  264. let response = res.response
  265. var el = $( '<div></div>' );
  266. el.html(response);
  267. let $border=$('.cartoon_online_border a', el);
  268. $.each($border,function(index){
  269. if (location.href.indexOf(this.href)>=0){
  270. ch_id=index;
  271. GM_addStyle('.el-menu>li:nth-child('+(ch_id+1)+'){background:rgba(255,165,0,.5) !important}')
  272. }
  273. sidebar_app.items.push({
  274. title:this.text,
  275. href:this.href,
  276. })
  277. })
  278. }
  279. })
  280. //预加载图片
  281. $('img').lazyload();
  282. //去除原来的jquery事件
  283. jQuery = unsafeWindow['jQuery'];
  284. if (jQuery!==undefined){
  285. jQuery("body").off("keydown");
  286. jQuery(".inner_img a").off("click");
  287. }
  288. //上下方向键滚动页面,左右方向键切换章节
  289. function scrollUp(){
  290. if (info_app.img_id==0) return;
  291. var id=g_max_pic_count+1;
  292. for (var i=1;i<=Math.min(info_app.img_id,g_max_pic_count);i++){
  293. var $img=$(".inner_img:eq("+(i-1)+")");
  294. if (((id_lock&&info_app.img_id>=1&&info_app.img_id<=g_max_pic_count)?$(".inner_img:eq("+(info_app.img_id-1)+")").offset().top:pageYOffset)<$img.offset().top+$img.height()+5){
  295. id=i;
  296. break;
  297. }
  298. }
  299. var $img=$(".inner_img:eq("+0+")");
  300. if (((id_lock&&info_app.img_id>=1&&info_app.img_id<=g_max_pic_count)?$(".inner_img:eq("+(info_app.img_id-1)+")").offset().top:pageYOffset)<$img.offset().top+5){
  301. console.log($img.offset().top+5);
  302. id=0;
  303. }
  304. var $img=$(".inner_img:eq("+(g_max_pic_count-1)+")");
  305. id_lock++;
  306. info_app.img_id=id;
  307. var $img=$(".inner_img:eq("+(id-1)+")");
  308. $("html").stop();
  309. if (id==0){
  310. $("html").animate({scrollTop: 0}, 500);
  311. }else{
  312. var $img=$(".inner_img:eq("+(id-1)+")");
  313. $("html").animate({scrollTop: $img.offset().top}, 500);
  314. }
  315. setTimeout(function(){id_lock--;},500);
  316. }
  317. function scrollDown(){
  318. if (info_app.img_id==g_max_pic_count+1) return;
  319. var id=g_max_pic_count+1;
  320. for (var i=Math.max(info_app.img_id,1);i<=g_max_pic_count;i++){
  321. var $img=$(".inner_img:eq("+(i-1)+")");
  322. if (((id_lock&&info_app.img_id>=1&&info_app.img_id<=g_max_pic_count)?$(".inner_img:eq("+(info_app.img_id-1)+")").offset().top:pageYOffset)<$img.offset().top-5){
  323. id=i;
  324. break;
  325. }
  326. }
  327. id_lock++;
  328. info_app.img_id=id;
  329. var $img=$(".inner_img:eq("+(id-1)+")");
  330. $("html").stop();
  331. if (id==g_max_pic_count+1){
  332. var $img=$(".inner_img:eq("+(g_max_pic_count-1)+")");
  333. $("html").animate({scrollTop: $img.offset().top+$img.height()}, 500);
  334. }else{
  335. var $img=$(".inner_img:eq("+(id-1)+")");
  336. $("html").animate({scrollTop: $img.offset().top}, 500);
  337. }
  338. setTimeout(function(){id_lock--;},500);
  339. }
  340. $("#center_box").click(function(event){
  341. if (event.clientY>$(window).height()/2){
  342. scrollDown();
  343. }else{
  344. scrollUp();
  345. }
  346. })
  347. $("body").keydown(function(event) {
  348. if (event.keyCode == 38) {
  349. scrollUp();
  350. } else if (event.keyCode == 40) {
  351. scrollDown();
  352. } else if (event.keyCode == 37) {
  353. let location_new = $("#prev_chapter").attr("href");
  354. if(location_new.indexOf("shtml")>=0)
  355. location.href = location_new;
  356. } else if (event.keyCode == 39) {
  357. let location_new = $("#next_chapter").attr("href");
  358. if(location_new.indexOf("shtml")>=0)
  359. location.href = location_new;
  360. }
  361. })
  362. //resize事件触发图片和浏览器对齐
  363. $(window).resize(function() {
  364. $("html").animate({scrollTop: $(".inner_img:eq("+(info_app.img_id)+")").offset().top}, 0);
  365. })
  366. function getID(){
  367. var id=0;
  368. for (var i=1;i<=g_max_pic_count;i++){
  369. var $img=$(".inner_img:eq("+(i-1)+")");
  370. if (pageYOffset>$img.offset().top-5&&pageYOffset<$img.offset().top+$img.height()-5){
  371. id=i;
  372. break;
  373. }
  374. }
  375. var $img=$(".inner_img:eq("+(g_max_pic_count-1)+")");
  376. if (pageYOffset>$img.offset().top+$img.height()-5){
  377. id=g_max_pic_count+1;
  378. }
  379. if (id_lock==0) info_app.img_id=id;
  380. }
  381. setInterval(getID,100);
  382. window.addEventListener('mousewheel', getID);
  383. })
  384. }
  385. })();