Warning: fopen(/www/sites/greasyfork.cloud/index/store/forever/b2f39680d391643a00975a1143949d91.html): failed to open stream: No space left on device in /www/sites/greasyfork.cloud/index/scriptsControl.php on line 127
Highlight Unread Novel - 源代码

Greasy Fork

Highlight Unread Novel

Highlight Unread Novel On Kakuyomu Narou Alphapolis Favorite Page

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

// ==UserScript==
// @name           Highlight Unread Novel
// @namespace      https://greasyfork.org/en/users/1264733
// @version        2024-03-19
// @description    Highlight Unread Novel On Kakuyomu Narou Alphapolis Favorite Page
// @author         LE37
// @license        MIT
// @include        https://kakuyomu.jp/my/antenna/works
// @include        https://syosetu.com/favnovelmain/list/
// @include        https://www.alphapolis.co.jp/mypage/notification/index/110000*
// @grant          none
// ==/UserScript==

(()=>{
	'use strict';
	let oUnread, no, oTot, oCur, oAlt;
	// Novel have > 3 unread episodes will be highlight
	const urNum = 3;
	switch (location.host) {
		case "kakuyomu.jp":
			oUnread = "li.widget-antennaList-unreadEpisodeCount b";
			Direct();
			break;
		case "syosetu.com":
			oUnread = "span.p-up-bookmark-item__unread-num";
			Direct();
			break;
		case "www.alphapolis.co.jp":
			oUnread = "div.content-main";
			oTot = "a.total";
			oCur = "a.disp-order";
			oAlt = "h2.title a";
			Calculate();
			break;
	}
	function Direct() {
		no = document.querySelectorAll(oUnread);
		for(let i = 0; i < no.length; i++) {
			if (parseInt(no[i].textContent) > urNum) {
				no[i].parentElement.style.color = "red";
			}
		}
	}
	function Calculate() {
		no = document.querySelectorAll(oUnread);
		for(let i = 0; i < no.length; i++) {
			const total = parseInt(no[i].querySelector(oTot).textContent.match(/[0-9]+/)[0]);
			const current = no[i].querySelector(oCur) ? parseInt(no[i].querySelector(oCur).textContent.match(/[0-9]+/)[0]) : 0;
			// Highlight novel's title if thers's no readed mark
			const alter = no[i].querySelector(oCur) ? no[i].querySelector(oCur) : no[i].querySelector(oAlt);
			if (total - current > urNum) {
				alter.style.color = "red";
			}
		}
	}
})();