ColaManga 瀏覽增強

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

目前為 2024-03-05 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         ColaManga 瀏覽增強
// @name:zh-TW   ColaManga 瀏覽增強
// @name:zh-CN   ColaManga 浏览增强
// @name:en      ColaManga Browsing Enhancement
// @version      0.0.6
// @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_setValue
// @grant        GM_getValue

// @require      https://update.greasyfork.org/scripts/487608/1337297/GrammarSimplified.js
// ==/UserScript==

(function () {
/*
只有設置是否使用該功能, 沒有設定參數, 這只是臨時的寫法, 之後會刪除掉
(0 = 不使用 | 1 = 使用 | mode = 有些有不同模式 2..3..n)
*/
const Config = {
    BlockAd: 1, // 使用阻擋廣告點擊
    BGColor: 1, // 使用背景換色 [目前還沒有自訂]
    RegisterHotkey: 3, // 快捷功能 mode: 1 = 翻頁, 2 = 翻頁+滾動, 3 翻頁+滾動+換頁繼續滾動
    AutoTurnPage: 1, // 使用自動換頁 mode: 1 = 自動換頁(敏感), 2 = 自動換頁(不敏感)
};
(new class Manga extends API {constructor() {super();this.ScrollSpeed = 1;this.JumpTrigger = !1;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.Device = {sY: ()=> {return window.scrollY},sX: ()=> {return window.scrollX},Width: ()=> {return window.innerWidth},Height: ()=> {return window.innerHeight},Agent: ()=> {return navigator.userAgent},_Type: undefined,Type: function() {if (this._Type) {return this._Type;} else if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(this.Agent()) || this.Width() < 768) {this._Type = "Mobile";} else {this._Type = "Desktop";}return this._Type;}};this.Get_Data = async (callback) => {this.WaitMap(["body", "div.mh_readtitle", "div.mh_headpager", "div.mh_readend a", "#mangalist"], 20, element => {let [Body, HomeLink, PageLink, BottomStrip, MangaList] = element;this.Body = Body;HomeLink = this.$$("a", !0, HomeLink);this.ContentsPage = HomeLink[0].href;this.HomePage = HomeLink[1].href;PageLink = this.$$("a.mh_btn:not(.mh_bgcolor)", !0, PageLink);this.PreviousPage = PageLink[0].href;this.NextPage = PageLink[1].href;this.MangaList = MangaList;this.BottomStrip = BottomStrip;if([this.Body,this.ContentsPage,this.HomePage,this.PreviousPage,this.NextPage,this.MangaList,this.BottomStrip].every(Check => Check)){callback(!0)}else {callback(!1)}}, document);};this.DetectionJumpLink = (link) => {return !link.startsWith("javascript");};this.throttle = (func, delay) => {let timer = null;return function() {let context=this, args=arguments;if (timer == null) {timer = setTimeout(function() {func.apply(context, args);timer = null;}, delay);}};};this.throttle_discard = (func, delay) => {let lastTime = 0;return function() {const context = this, args = arguments, now = Date.now();if ((now - lastTime) >= delay) {func.apply(context, args);lastTime = now;}};};this.TopDetected = this.throttle_discard(()=>{this.Up_scroll = this.Device.sY() == 0 ? !1 : !0;}, 1000);this.BottomDetected = this.throttle_discard(()=>{this.Down_scroll =this.Device.sY() + this.Device.Height() >= document.documentElement.scrollHeight ? !1 : !0;}, 1000);this.scroll = (move) => {if (this.Up_scroll && move < 0) {this.TopDetected();requestAnimationFrame(() => {window.scrollBy(0, move);this.scroll(move);});} else if (this.Down_scroll && move > 0) {this.BottomDetected();requestAnimationFrame(() => {window.scrollBy(0, move);this.scroll(move);});}};this.Get_Style = () => {const Style = this.store("get", "Style") ||[{"BG_Color": "#595959","Img_Bw": "auto","Img_Mw": "100%"}];return Style[0];};this.ImgStyle = this.Get_Style();}async BlockAds() {let iframe;this.AdCleanup = setInterval(() => {iframe = this.$$("iframe"); iframe && iframe.remove()}, 600);if (this.Device.Type() == "Desktop") {this.AddStyle(`body {pointer-events: none;}body .mh_wrap, .modal-background {pointer-events: auto;}`, "Inject-Blocking-Ads");} else if (this.Device.Type() == "Mobile") {this.AddListener(window, "pointerup", event => {event.stopImmediatePropagation();}, { capture: !0, passive: !0 });this.AddListener(document, "pointerup", event => {event.stopImmediatePropagation();}, { capture: !0, passive: !0 });this.AddListener(window, "click", event => {event.stopImmediatePropagation();}, { capture: !0, passive: !0 });this.AddListener(document, "click", event => {event.stopImmediatePropagation();}, { capture: !0, passive: !0 });}}async BackgroundStyle() {this.Body.style.backgroundColor=this.ImgStyle.BG_Color;}async PictureStyle() {if (this.Device.Type() == "Desktop") {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 click = new MouseEvent("click", { bubbles: !0, cancelable: !0 });const observer = new IntersectionObserver(observed => {observed.forEach(entry => { entry.isIntersecting && entry.target.dispatchEvent(click) });}, { threshold: .3 });this.$$("span.mh_btn:not(.contact)", !0, this.MangaList).forEach(b => { observer.observe(b) });} catch {}}async Hotkey_Switch(mode) {if (this.Device.Type() == "Desktop") {if (mode == 3) {this.Down_scroll = this.store("get", "scroll");this.scroll(this.ScrollSpeed);}const UP_ScrollSpeed = this.ScrollSpeed * -1;this.AddListener(document, "keydown", event => {const key = event.key;if (key == "ArrowLeft" && !this.JumpTrigger) {this.JumpTrigger = this.DetectionJumpLink(this.PreviousPage) ? !0 : !1;location.assign(this.PreviousPage);}else if (key == "ArrowRight" && !this.JumpTrigger) {this.JumpTrigger = this.DetectionJumpLink(this.NextPage) ? !0 : !1;location.assign(this.NextPage);}else if (key == "ArrowUp" && mode >= 2) {event.preventDefault();if (this.Up_scroll) {this.Up_scroll = !1;} else if (!this.Up_scroll || this.Down_scroll) {this.Down_scroll = !1;this.Up_scroll = !0;this.scroll(UP_ScrollSpeed);}}else if (key == "ArrowDown" && mode >= 2) {event.preventDefault();if (this.Down_scroll) {this.Down_scroll = !1;this.store("set","scroll",!1);} else if (this.Up_scroll || !this.Down_scroll) {this.Up_scroll = !1;this.Down_scroll = !0;this.store("set","scroll",!0);this.scroll(this.ScrollSpeed);}}}, { capture: !0 });} else if (this.Device.Type() == "Mobile") {const sidelineX = .35 * this.Device.Width(), sidelineY = (this.Device.Height() / 4) * .2;let startX, startY, moveX, moveY;this.AddListener(this.MangaList, "touchstart", event => {startX = event.touches[0].clientX;startY = event.touches[0].clientY;}, { passive: !0 });this.AddListener(this.MangaList, "touchmove", this.throttle(event => {requestAnimationFrame(() => {moveX = event.touches[0].clientX - startX;moveY = event.touches[0].clientY - startY;if (Math.abs(moveY) < sidelineY) {if (moveX > sidelineX && !this.JumpTrigger) {this.JumpTrigger = this.DetectionJumpLink(this.PreviousPage) ? !0 : !1;location.assign(this.PreviousPage);} else if (moveX < -sidelineX && !this.JumpTrigger) {this.JumpTrigger = this.DetectionJumpLink(this.NextPage) ? !0 : !1;location.assign(this.NextPage);}}});}, 200), { passive: !0 });}}async Automatic_Next(mode) {const self = this, img = self.$$("img", !0, self.MangaList), lest_img = img[Math.floor(img.length * .7)];let hold;self.Observer_Next = new IntersectionObserver(observed => {observed.forEach(entry => {if (entry.isIntersecting && lest_img.src) {self.Observer_Next.disconnect();self.DetectionJumpLink(self.NextPage) && location.assign(self.NextPage);}});}, { threshold: hold });hold = mode >= 2 ? 1 : .1;self.Observer_Next.observe(mode >= 2 ? self.$$("div.endtip2.clear") : self.BottomStrip);}async Injection() {try {Config.BlockAd > 0 && this.BlockAds();this.Get_Data(state=> {if (state) {Config.BGColor > 0 && this.BackgroundStyle();this.PictureStyle();Config.RegisterHotkey > 0 && this.Hotkey_Switch(Config.RegisterHotkey);Config.AutoTurnPage > 0 && this.Automatic_Next(Config.AutoTurnPage);}});} catch (error) {this.log(null, error)}}}).Injection();
})();