// ==UserScript== // @name ColaManga 瀏覽增強 // @name:zh-TW ColaManga 瀏覽增強 // @name:zh-CN ColaManga 浏览增强 // @name:en ColaManga Browsing Enhancement // @version 0.0.3 // @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://greasyfork.org/users/989635 // @run-at document-body // @grant GM_getValue // @require https://update.greasyfork.icu/scripts/487608/1333587/GrammarSimplified.js // @downloadURL none // ==/UserScript== (function(){class f extends API{constructor(){super();this.DEV=!1;this.Observer_Next=this.Rotation_Down=this.Rotation_Up=this.Interval=this.BottomStrip=this.MangaList=this.NextPage=this.PreviousPage=this.HomePage=this.ContentsPage=this.GetStatus=null;this.Get_Data=async()=>{this.WaitMap(["div.mh_readtitle","div.mh_headpager","div.mh_readend","#mangalist"],20,a=>{let [c,b,d,e]=a;c=this.$$("a",!0,c);this.ContentsPage=c[0].href;this.HomePage=c[1].href;b=this.$$("a.mh_prevbook",!0,b);this.PreviousPage=b[0].href;this.NextPage=b[1].href;this.MangaList=e;d=this.$$("a",!0,d);this.BottomStrip=d[d.length-1];this.GetStatus=[this.ContentsPage,this.HomePage,this.PreviousPage,this.NextPage,this.MangaList,this.BottomStrip].every(g=>g)})};this.RegisterRotation=(a,c,b)=>a=setInterval(()=>{window.scrollBy(0,c)},b);this.CleanRotation=a=>{clearInterval(a);return null};this.Get_Style=()=>(this.store("get","Style")||[{BG_Color:"#595959",Img_Bw:"auto",Img_Mw:"100%"}])[0];this.ImgStyle=this.Get_Style()}async BlockAds(){this.Interval=setInterval(()=>{const a=this.$$("iframe");a&&a.remove()},1E3);this.AddStyle("body {pointer-events: none;}body AdvertisingBezel,.mh_wrap,.modal-background {pointer-events: auto;}#mangalist {position: relative;}AdvertisingBezel {top: 0;left: 0;width: 100%;height: 100%;display: flex;z-index: 9999;overflow: auto;position: absolute;}","Inject-Blocking-Ads");this.MangaList.appendChild(document.createElement("AdvertisingBezel"));this.DEV&&this.log("\u5ee3\u544a\u963b\u64cb\u6ce8\u5165",!0)}async BackgroundStyle(){document.body.style.backgroundColor=this.ImgStyle.BG_Color;this.DEV&&this.log("\u80cc\u666f\u984f\u8272\u6ce8\u5165",!0)}async PictureStyle(){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");this.AutoReload();this.DEV&&this.log("\u5716\u7247\u6a23\u5f0f\u6ce8\u5165",!0)}async AutoReload(){try{let a=new MouseEvent("click",{bubbles:!0,cancelable:!0});const c=new IntersectionObserver(b=>{b.forEach(d=>{d.isIntersecting&&d.target.dispatchEvent(a)})},{threshold:1});this.$$("span.mh_btn:not(.contact)",!0,this.MangaList).forEach(b=>{c.observe(b)});this.DEV&&this.log("\u81ea\u52d5\u91cd\u8f09\u6ce8\u5165",!0)}catch{this.DEV&&this.log("\u81ea\u52d5\u91cd\u8f09\u6ce8\u5165\u5931\u6557",!1)}}async Hotkey_Switch(){this.GetStatus?(this.AddListener(document,"keydown",a=>{a=a.key;"ArrowLeft"==a?location.assign(this.PreviousPage):"ArrowRight"==a?location.assign(this.NextPage):"ArrowUp"==a?(this.Rotation_Down=this.Rotation_Down&&this.CleanRotation(this.Rotation_Down),this.Rotation_Up=this.Rotation_Up?this.CleanRotation(this.Rotation_Up):this.RegisterRotation(this.Rotation_Up,-2,7)):"ArrowDown"==a&&(this.Rotation_Up=this.Rotation_Up&&this.CleanRotation(this.Rotation_Up),this.Rotation_Down=this.Rotation_Down?this.CleanRotation(this.Rotation_Down):this.RegisterRotation(this.Rotation_Down,2,7))},{capture:!0,passive:!0}),this.DEV&&this.log("\u63db\u9801\u5feb\u6377\u6ce8\u5165",!0)):this.DEV&&this.log("\u7121\u53d6\u5f97\u63db\u9801\u6578\u64da",!1)}async Automatic_Next(){if(this.GetStatus){const a=this,c=a.$$("img",!0,a.MangaList),b=c[Math.floor(.7*c.length)];a.Observer_Next=new IntersectionObserver(d=>{d.forEach(e=>{e.isIntersecting&&b.src&&location.assign(a.NextPage)})},{threshold:.1});a.Observer_Next.observe(a.BottomStrip);this.DEV&&this.log("\u89c0\u5bdf\u63db\u9801\u6ce8\u5165",!0)}else this.DEV&&this.log("\u7121\u53d6\u5f97\u63db\u9801\u6578\u64da",!1)}async SettingMenu(){this.GetStatus||this.DEV&&this.log("\u7121\u53d6\u5f97\u63db\u9801\u6578\u64da",!1)}async MenuStyle(){this.AddStyle("\n","Inject_MenuStyle")}async Injection(){try{this.Get_Data();this.BackgroundStyle();const a=setInterval(()=>{null!=this.GetStatus&&(clearInterval(a),this.BlockAds(),this.PictureStyle(),this.Hotkey_Switch(),this.SettingMenu(),this.Automatic_Next())},300)}catch(a){this.DEV&&this.log(null,a)}}}(new f).Injection()})();