ColaManga 浏览增强

隐藏广告内容,阻止广告点击,提昇浏览体验。自定义背景颜色,调整图片大小。当图片载入失败时,自动重新载入图片。提供快捷键功能:[← 上一页]、[下一页 →]、[↑ 自动上滚动]、[↓ 自动下滚动]。当用户滚动到页面底部时,自动跳转到下一页。

目前为 2024-03-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         ColaManga 瀏覽增強
// @name:zh-TW   ColaManga 瀏覽增強
// @name:zh-CN   ColaManga 浏览增强
// @name:en      ColaManga Browsing Enhancement
// @version      0.0.9
// @author       HentaiSaru
// @description       隱藏廣告內容,阻止廣告點擊,提昇瀏覽體驗。自訂背景顏色,圖片大小調整。當圖片載入失敗時,自動重新載入圖片。提供熱鍵功能:[← 上一頁]、[下一頁 →]、[↑ 自動上滾動]、[↓ 自動下滾動]。當用戶滾動到頁面底部時,自動跳轉到下一頁。
// @description:zh-TW 隱藏廣告內容,阻止廣告點擊,提昇瀏覽體驗。自訂背景顏色,圖片大小調整。當圖片載入失敗時,自動重新載入圖片。提供熱鍵功能:[← 上一頁]、[下一頁 →]、[↑ 自動上滾動]、[↓ 自動下滾動]。當用戶滾動到頁面底部時,自動跳轉到下一頁。
// @description:zh-CN 隐藏广告内容,阻止广告点击,提昇浏览体验。自定义背景颜色,调整图片大小。当图片载入失败时,自动重新载入图片。提供快捷键功能:[← 上一页]、[下一页 →]、[↑ 自动上滚动]、[↓ 自动下滚动]。当用户滚动到页面底部时,自动跳转到下一页。
// @description:en    Hide advertisement content, block ad clicks, enhance browsing experience. Customize background color, adjust image size. Automatically reload images when they fail to load. Provide shortcut key functionalities: [← Previous Page], [Next Page →], [↑ Auto Scroll Up], [↓ Auto Scroll Down]. Automatically jump to the next page when users scroll to the bottom of the page.

// @match        *://www.colamanga.com/manga-*/*/*.html
// @icon         https://www.colamanga.com/favicon.png

// @license      MIT
// @namespace    https://gf.qytechs.cn/users/989635

// @run-at       document-start
// @grant        GM_getValue
// @require      https://update.gf.qytechs.cn/scripts/487608/1339711/GrammarSimplified.js
// ==/UserScript==

!function(){
/* (0 = 不使用 | 1 = 使用 | mode = 有些有不同模式 2..3..n) */
const e={
    BlockAd: 1, // 阻擋廣告點擊
    BGColor: 1, // 背景換色 [目前還沒有自訂]
    RegisterHotkey: 3, // 快捷功能 mode: 1 = 翻頁, 2 = 翻頁+滾動, 3 翻頁+滾動+換頁繼續滾動
    AutoTurnPage: 4, // 自動換頁 mode: 1 = 快速, 2 = 普通, 3 = 緩慢, 4 = 無盡 (實驗中的酷東西)
};
(new class extends API{constructor(){super(),this.ScrollSpeed=2,this.JumpTrigger=!1,this.WaitPicture=1500,this.AdCleanup=this.Body=null,this.ContentsPage=this.HomePage=null,this.PreviousPage=this.NextPage=null,this.MangaList=this.BottomStrip=null,this.Up_scroll=this.Down_scroll=!1,this.Observer_Next=null,this.Origin=location.origin,this.CurrentPage=document.URL,this.IsMainPage=window.self===window.parent,this.RecordName=location.pathname.split("/")[1],this.RecordURL=this.Storage(localStorage,this.RecordName)||this.CurrentPage,this.Device={sY:()=>window.scrollY,sX:()=>window.scrollX,Width:()=>window.innerWidth,Height:()=>window.innerHeight,Agent:()=>navigator.userAgent,_Type:void 0,Type:function(){return this._Type||(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(this.Agent())||this.Width()<768?this._Type="Mobile":this._Type="Desktop"),this._Type}},this.Get_Data=async r=>{"Mobile"==this.Device.Type()&&(this.WaitMap=(t,e,i,s)=>{let o,n;const r=setInterval(()=>{(n=t.map(t=>document.querySelector(t))).every(t=>null!==t&&"string")&&(clearInterval(r),clearTimeout(o),i(n))},100);o=setTimeout(()=>{clearInterval(r)},1e3*e)}),this.WaitMap(["body","div.mh_readtitle","div.mh_headpager","div.mh_readend","#mangalist"],20,t=>{var[t,e,i,s,o]=t,t=(this.Body=t,this.$$("a",!0,e));this.ContentsPage=t[0].href,this.HomePage=t[1].href;try{var n=this.$$("ul a",!0,s);this.PreviousPage=n[0].href,this.NextPage=n[2].href}catch{e=this.$$("a.mh_btn:not(.mh_bgcolor)",!0,i);this.PreviousPage=e[0].href,this.NextPage=e[1].href}this.MangaList=o,this.BottomStrip=this.$$("a",!1,s),[this.Body,this.ContentsPage,this.HomePage,this.PreviousPage,this.NextPage,this.MangaList,this.BottomStrip].every(t=>t)?r(!0):r(!1)},document)},this.storage=(t,e=null)=>null!=e?this.Storage(sessionStorage,t,e):this.Storage(sessionStorage,t),this.DetectionJumpLink=t=>!t.startsWith("javascript"),this.throttle=(i,s)=>{let o=null;return function(){let t=this,e=arguments;null==o&&(o=setTimeout(function(){i.apply(t,e),o=null},s))}},this.throttle_discard=(i,s)=>{let o=0;return function(){var t=arguments,e=Date.now();e-o>=s&&(i.apply(this,t),o=e)}},this.TopDetected=this.throttle_discard(()=>{this.Up_scroll=0!=this.Device.sY()||(this.storage("scroll",!1),!1)},1e3),this.BottomDetected=this.throttle_discard(()=>{this.Down_scroll=!(this.Device.sY()+this.Device.Height()>=document.documentElement.scrollHeight&&(this.storage("scroll",!1),1))},1e3),this.scroll=t=>{this.Up_scroll&&t<0?(this.TopDetected(),requestAnimationFrame(()=>{window.scrollBy(0,t),this.scroll(t)})):this.Down_scroll&&0<t&&(this.BottomDetected(),requestAnimationFrame(()=>{window.scrollBy(0,t),this.scroll(t)}))},this.ObserveValue=t=>t[Math.floor(.7*t.length)],this.DetectionValue=t=>t.filter(t=>0!=t.height).length>=Math.floor(.5*t.length),this.Get_Style=()=>{return(this.store("get","Style")||[{BG_Color:"#595959",Img_Bw:"auto",Img_Mw:"100%"}])[0]},this.ImgStyle=this.Get_Style()}async BlockAds(){let t;this.AdCleanup=setInterval(()=>{(t=this.$$("iframe:not(#Iframe-Comics)"))&&t.remove()},600),"Desktop"==this.Device.Type()?this.AddStyle(`body {pointer-events: none;}body .mh_wrap, span.mh_btn:not(.contact), #Iframe-Comics {pointer-events: auto;}`,"Inject-Blocking-Ads"):"Mobile"==this.Device.Type()&&(this.Listen(window,"pointerup",t=>{t.stopImmediatePropagation()},{capture:!0,passive:!0}),this.Listen(window,"click",t=>{t.stopImmediatePropagation()},{capture:!0,passive:!0}),this.Listen(document,"pointerup",t=>{t.stopImmediatePropagation()},{capture:!0,passive:!0}),this.Listen(document,"click",t=>{t.stopImmediatePropagation()},{capture:!0,passive:!0}))}async BackgroundStyle(){this.Body.style.backgroundColor=this.ImgStyle.BG_Color}async PictureStyle(){"Desktop"==this.Device.Type()&&this.AddStyle(`.mh_comicpic img {vertical-align: top;cursor: pointer;display: block;margin: auto;width: ${this.ImgStyle.Img_Bw};max-width: ${this.ImgStyle.Img_Mw};}`,"Inject-Image-Style"),setTimeout(()=>{this.AutoReload()},this.WaitPicture)}async AutoReload(){let e=new MouseEvent("click",{bubbles:!0,cancelable:!0});const i=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&t.target.dispatchEvent(e)})},{threshold:.3});this.$$("span.mh_btn:not(.contact)",!0,this.MangaList).forEach(t=>{i.observe(t)})}async Hotkey_Switch(i){if("Desktop"==this.Device.Type()){3==i&&this.IsMainPage&&(this.Down_scroll=this.storage("scroll"),this.Down_scroll)&&this.scroll(this.ScrollSpeed);const s=-1*this.ScrollSpeed;this.Listen(window,"keydown",t=>{var e=t.key;"ArrowLeft"!=e||this.JumpTrigger?"ArrowRight"!=e||this.JumpTrigger?"ArrowUp"==e&&2<=i?(t.stopImmediatePropagation(),t.preventDefault(),this.Up_scroll?this.Up_scroll=!1:this.Up_scroll&&!this.Down_scroll||(this.Down_scroll=!1,this.Up_scroll=!0,this.scroll(s))):"ArrowDown"==e&&2<=i&&(t.stopImmediatePropagation(),t.preventDefault(),this.Down_scroll?(this.Down_scroll=!1,this.storage("scroll",!1)):!this.Up_scroll&&this.Down_scroll||(this.Up_scroll=!1,this.Down_scroll=!0,this.storage("scroll",!0),this.scroll(this.ScrollSpeed))):(t.stopImmediatePropagation(),this.JumpTrigger=!!this.DetectionJumpLink(this.NextPage),location.assign(this.NextPage)):(t.stopImmediatePropagation(),this.JumpTrigger=!!this.DetectionJumpLink(this.PreviousPage),location.assign(this.PreviousPage))},{capture:!0})}else if("Mobile"==this.Device.Type()){const n=.35*this.Device.Width(),r=this.Device.Height()/4*.2;let e,i,s,o;this.Listen(window,"touchstart",t=>{e=t.touches[0].clientX,i=t.touches[0].clientY},{passive:!0}),this.Listen(window,"touchmove",this.throttle(t=>{requestAnimationFrame(()=>{s=t.touches[0].clientX-e,o=t.touches[0].clientY-i,Math.abs(o)<r&&(s>n&&!this.JumpTrigger?(this.JumpTrigger=!!this.DetectionJumpLink(this.PreviousPage),location.assign(this.PreviousPage)):s<-n&&!this.JumpTrigger&&(this.JumpTrigger=!!this.DetectionJumpLink(this.NextPage),location.assign(this.NextPage)))})},200),{passive:!0})}}async Automatic_Next(t){let e=this,i,s,o;switch(e.Observer_Next=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&e.DetectionValue(o)&&(e.Observer_Next.disconnect(),e.DetectionJumpLink(e.NextPage))&&location.assign(e.NextPage)})},{threshold:i}),t){case 2:i=.5,s=e.$$("li:nth-child(3) a.read_page_link");break;case 3:i=1,s=e.$$("div.endtip2.clear");break;case 4:this.SpecialPageTurning();break;default:i=.1,s=e.BottomStrip}4!=t&&setTimeout(()=>{o=e.$$("img",!0,e.MangaList),e.Observer_Next.observe(s)},e.WaitPicture)}async SpecialPageTurning(){const i=this,s=document.createElement("iframe");s.id="Iframe-Comics",s.src=i.NextPage,i.AddStyle(`.mh_wrap, .mh_readend, .mh_footpager, .fed-foot-info, #imgvalidation2022 {display: none;}#Iframe-Comics {height:0px; border: none; width: 100%;}`,"scroll-hidden");let o,n,r=i.$$("#scroll-hidden").sheet.cssRules,e;if(i.Observer_Next=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&i.DetectionValue(e)&&(i.Observer_Next.disconnect(),i.DetectionJumpLink(i.NextPage)?async function(){requestAnimationFrame(()=>{document.body.appendChild(i.Buffer),function t(){s.onload=function(){(o=s.contentWindow.location.href)!=i.NextPage&&(s.src=i.NextPage,t()),(n=s.contentWindow.document).body.style.overflow="hidden",setInterval(()=>{var t=n.body.scrollHeight;r[1].style.height=t+"px"},1500);const e=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&(e.disconnect(),window.parent.postMessage(o,i.Origin))})},{threshold:.1});e.observe(i.$$("#mangalist img",!1,n))}}()})}():r[0].style.display="block")})},{threshold:.1}),setTimeout(()=>{e=i.$$("img",!0,i.MangaList),i.Observer_Next.observe(i.ObserveValue(e))},i.WaitPicture),i.IsMainPage)this.Listen(window,"message",t=>{history.pushState(null,null,t.data)});else{let e=window;this.Listen(window,"message",t=>{for(;e.parent!==e;)e=e.parent;e.postMessage(t.data,i.Origin)})}i.Buffer.appendChild(s)}async SettingMenu(){}async MenuStyle(){this.AddStyle("","Inject_MenuStyle")}async Injection(){try{0<e.BlockAd&&this.BlockAds(),this.Get_Data(t=>{t&&(0<e.BGColor&&this.BackgroundStyle(),this.PictureStyle(),0<e.RegisterHotkey&&this.Hotkey_Switch(e.RegisterHotkey),0<e.AutoTurnPage)&&this.Automatic_Next(e.AutoTurnPage)})}catch(t){this.log(null,t)}}}).Injection()
}();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址