您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
如果點擊的集數比最後觀看的集數還要高,會自動跳轉到最後觀看的下一集。若當前集數在最後觀看集數之前,則不跳轉,若無法找到最後觀看的集數,則跳轉到第一集,並在跳轉後檢查是否最後觀看集數為最新一集,若是,則跳回最新一集。
// ==UserScript== // @name 動畫瘋 避免跳集觀看 // @namespace https://ani.gamer.com.tw/ // @version 1.1 // @description 如果點擊的集數比最後觀看的集數還要高,會自動跳轉到最後觀看的下一集。若當前集數在最後觀看集數之前,則不跳轉,若無法找到最後觀看的集數,則跳轉到第一集,並在跳轉後檢查是否最後觀看集數為最新一集,若是,則跳回最新一集。 // @license MIT // @author movwei // @match https://ani.gamer.com.tw/animeVideo.php?sn=* // ==/UserScript== (function() { 'use strict'; // 取得當前影片的集數編號 let currentEpisode = window.location.search; // 取得所有集數列表 let episodeList = Array.from(document.querySelectorAll('.season li a')); // 找到播放中的集數和已觀看的集數 let playingElement = document.querySelector('.season .playing'); let sawElement = document.querySelector('.season .saw'); // 若無最後觀看集數,跳轉至第一集 if (!sawElement) { if (!sessionStorage.getItem('redirectedFor' + currentEpisode)) { let firstEpisode = document.querySelector('.season li:first-child a').href; sessionStorage.setItem('redirectedFor' + currentEpisode, 'true'); window.location.href = firstEpisode; return; // 終止當前腳本執行 } else { return; // 若已跳轉至第一集且沒有最後觀看集數,終止腳本執行 } } // 當前集數為第一集,並且最後觀看的集數為最新一集 if (playingElement && !sawElement.nextElementSibling) { let lastEpisode = document.querySelector('.season li:last-child a').href; let lastEpisodeSearch = new URL(lastEpisode).search; if (sawElement.querySelector('a').search === lastEpisodeSearch) { window.location.href = lastEpisode; return; // 終止當前腳本執行 } } // 找到已觀看的下一集 let nextEpisode = sawElement.nextElementSibling; // 取得當前集數的索引 let currentEpisodeIndex = episodeList.findIndex(ep => ep.href.endsWith(currentEpisode)); // 取得已觀看集數的索引 let sawEpisodeIndex = episodeList.findIndex(ep => ep.href.endsWith(sawElement.querySelector('a').search)); // 如果當前集數在已觀看集數之前,不跳轉 if (currentEpisodeIndex <= sawEpisodeIndex) { return; } // 如果下一集存在且不是目前播放中的集數 if (nextEpisode && !nextEpisode.classList.contains('playing')) { let nextEpisodeLink = nextEpisode.querySelector('a').href; window.location.href = nextEpisodeLink; } })();