ColaManga 瀏覽增強

隱藏廣告內容,阻止廣告點擊,提昇瀏覽體驗。自訂背景顏色,圖片大小調整。當圖片載入失敗時,自動重新載入圖片。提供熱鍵功能:[← 上一頁]、[下一頁 →]、[↑ 自動上滾動]、[↓ 自動下滾動]。當用戶滾動到頁面底部時,自動跳轉到下一頁。

当前为 2024-03-08 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ColaManga 瀏覽增強
// @name:zh-TW   ColaManga 瀏覽增強
// @name:zh-CN   ColaManga 浏览增强
// @name:en      ColaManga Browsing Enhancement
// @version      0.0.8
// @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-start
// @grant        GM_getValue
// @require      https://update.greasyfork.org/scripts/487608/1338920/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.CurrentPage=document.URL,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.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 o=>{this.WaitMap(["body","div.mh_readtitle","div.mh_readend","#mangalist"],20,t=>{var[t,e,i,s]=t,t=(this.Body=t,this.$$("a",!0,e)),e=(this.ContentsPage=t[0].href,this.HomePage=t[1].href,this.$$("ul a",!0,i));this.PreviousPage=e[0].href,this.NextPage=e[2].href,this.MangaList=s,this.BottomStrip=this.$$("a",!1,i),[this.Body,this.ContentsPage,this.HomePage,this.PreviousPage,this.NextPage,this.MangaList,this.BottomStrip].every(t=>t)?o(!0):o(!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=e=>{var t=e.length;return[.9*t,.7*t,t*(.5*Math.random()+.1).toPrecision(2)].map(t=>e[Math.floor(t)])},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 iframe, .mh_wrap, .modal-background {pointer-events: auto;}`,"Inject-Blocking-Ads"):"Mobile"==this.Device.Type()&&(this.Listen(window,"pointerup",t=>{t.stopImmediatePropagation()},{capture:!0,passive:!0}),this.Listen(document,"pointerup",t=>{t.stopImmediatePropagation()},{capture:!0,passive:!0}),this.Listen(window,"click",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"),this.AutoReload()}async AutoReload(){try{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)})}catch{}}async Hotkey_Switch(i){if("Desktop"==this.Device.Type()){3==i&&window.self==window.parent&&(this.Down_scroll=this.storage("scroll"),this.Down_scroll)&&this.scroll(this.ScrollSpeed);const s=-1*this.ScrollSpeed;this.AddListener(document,"keydown",t=>{var e=t.key;"ArrowLeft"!=e||this.JumpTrigger?"ArrowRight"!=e||this.JumpTrigger?"ArrowUp"==e&&2<=i?(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.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))):(this.JumpTrigger=!!this.DetectionJumpLink(this.NextPage),location.assign(this.NextPage)):(this.JumpTrigger=!!this.DetectionJumpLink(this.PreviousPage),location.assign(this.PreviousPage))},{capture:!0})}else if("Mobile"==this.Device.Type()){const r=.35*this.Device.Width(),n=this.Device.Height()/4*.2;let e,i,s,o;this.AddListener(this.MangaList,"touchstart",t=>{e=t.touches[0].clientX,i=t.touches[0].clientY},{passive:!0}),this.AddListener(this.MangaList,"touchmove",this.throttle(t=>{requestAnimationFrame(()=>{s=t.touches[0].clientX-e,o=t.touches[0].clientY-i,Math.abs(o)<n&&(s>r&&!this.JumpTrigger?(this.JumpTrigger=!!this.DetectionJumpLink(this.PreviousPage),location.assign(this.PreviousPage)):s<-r&&!this.JumpTrigger&&(this.JumpTrigger=!!this.DetectionJumpLink(this.NextPage),location.assign(this.NextPage)))})},200),{passive:!0})}}async Automatic_Next(t){const e=this,[i,s,o]=e.ObserveValue(e.$$("img",!0,e.MangaList));let r,n;switch(e.Observer_Next=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&(i.src||s.src||o.src)&&(e.Observer_Next.disconnect(),e.DetectionJumpLink(e.NextPage))&&location.assign(e.NextPage)})},{threshold:r}),t){case 2:r=.5,n=e.$$("li:nth-child(3) a.read_page_link");break;case 3:r=1,n=e.$$("div.endtip2.clear");break;case 4:e.AddStyle(`.mh_wrap, .mh_readend, .mh_footpager, .fed-foot-info {display: none;}#Iframe-Comics {height:0px; border: none; width: 100%;}`,"scroll-hidden"),this.SpecialPageTurning();break;default:r=.1,n=e.BottomStrip}4!=t&&e.Observer_Next.observe(n)}async SpecialPageTurning(){const i=this,[e,s,o]=i.ObserveValue(i.$$("img",!0,i.MangaList)),r=document.createElement("iframe");r.id="Iframe-Comics",requestAnimationFrame(()=>{document.body.appendChild(r)});let n,a,h=i.$$("#scroll-hidden").sheet.cssRules;i.Observer_Next=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&(e.src||s.src||o.src)&&(i.Observer_Next.disconnect(),i.DetectionJumpLink(i.NextPage)?function t(e){requestAnimationFrame(()=>{r.src=e});r.onload=function(){(n=r.contentWindow.location.href)!=e&&t(e),(a=r.contentWindow.document).body.style.overflow="hidden",setInterval(()=>{h[1].style.height=a.body.scrollHeight+"px"},1500),i.Storage(localStorage,i.RecordName,e)}}(i.NextPage):h[0].style.display="block")})},{threshold:.1}),i.Observer_Next.observe(e)}async Injection(){try{0<e.BlockAd&&this.BlockAds(),this.RecordURL!=this.CurrentPage&&(this.Storage(localStorage,this.RecordName,!1),location.assign(this.RecordURL)),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()
}();