MyAnimeList (MAL) Alternative History

Displays anime/manga series history based on RSS feed, instead of default episode/chapter history.

目前為 2015-04-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name         MyAnimeList (MAL) Alternative History
// @namespace    https://gf.qytechs.cn/users/7517
// @description  Displays anime/manga series history based on RSS feed, instead of default episode/chapter history.
// @version      1.2.1
// @author       akarin
// @include      /^http\:\/\/myanimelist\.net\/history/
// @grant        none
// ==/UserScript==

;(function() {  	
	var FEED_ANIME = 1
	var FEED_MANGA = 2
	
	var animeHistory = document.URL.match(/\/anime$/) ? true : false
	var mangaHistory = document.URL.match(/\/manga$/) ? true : false
	var allHistory = (animeHistory || mangaHistory) ? false : true
	
	var nickname = allHistory ? 
			document.URL.match(/\/history\/(.+)$/)[1] : 
			document.URL.match(/\/history\/(.+)(\/anime|\/manga)$/)[1]
	
	var feeds = 0
	var feeds_max = allHistory ? 2 : 1
	var entries = []
	
	if (allHistory || animeHistory) {		
		$.get('http://myanimelist.net/rss.php?type=rw&u=' + nickname, function(data) {
			process(data, FEED_ANIME)
		})
	}
	
	if (allHistory || mangaHistory) {	
		$.get('http://myanimelist.net/rss.php?type=rm&u=' + nickname, function(data) {
			process(data, FEED_MANGA)
		})
	}

	function process(data, feedType) {	
		$('rss > channel > item', data).each(function() {	
			var entry = {
				title: $('title', this).text().match(/^(.+)( - (?!.* - ))/)[1],
				type: $('title', this).text().match(/( - (?!.* - ))(.+)$/)[2],
				link: $('link', this).text(),
				status: $('description', this).text().match(/^(.+) - /)[1],
				progress: $('description', this).text().match(/ - (.+)$/)[1],
				date: new Date($('pubDate', this).text())
			}
			
			if (feedType === FEED_MANGA) {
			    entry.status = entry.status.replace('Watching', 'Reading')
			    entry.progress = entry.progress.replace(' chapters', '')
			}
			else {
			    entry.progress = entry.progress.replace(' episodes', '')
			}
			
			entry.progress = entry.progress.replace(' of ', '/')
			entry.progress = entry.progress.replace(/^0\//, '-/')
			entry.progress = entry.progress.replace('?', '-')
			
			entries.push(entry)
		})
		
		if ((++feeds) < feeds_max) {
			return
		}
		
		if (entries.length === 0) {
			return
		}
		
		var $content = $('<div id="history_content" style="padding: 0 15px 10px 15px;"></div>')
		$('#horiznav_nav + div').hide().before($content)
		
		var $table = $('<table id="history_table" width="100%" border="0" cellpadding="0" cellspacing="0"></table>')
		
		$table.append($('<tr></tr>')
			.append('<td class="normal_header">Title</td>')
			.append('<td class="normal_header" width="70" align="center">Type</td>')
			.append('<td class="normal_header" width="90" align="center">Status</td>')
			.append('<td class="normal_header" width="70" align="center">Progress</td>')
			.append('<td class="normal_header" width="125" align="center">Date</td>')
		)
		
		entries.sort(function(a, b) {
			return b.date - a.date
		})
		
		$.each(entries, function(index, entry) {
			var formatDate = entry.date.toLocaleTimeString('en-US', {
				year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', hour12: false, minute: '2-digit'
			})
			
			var dateLast = (index < entries.length - 1) && (entry.date.getDate() != entries[index + 1].date.getDate()) ? true : false
			
			$table.append($('<tr' + (dateLast ? ' class="date_last"' : '') + '></tr>')
				.append($('<td></td>').append('<a href="' + entry.link + '">' + entry.title + '</a>'))
				.append('<td width="70" align="center">' + entry.type + '</td>')
				.append('<td width="90" align="center">' + entry.status + '</td>')
				.append('<td width="70" align="center">' + entry.progress + '</td>')
				.append('<td width="125" align="center">' + formatDate + '</td>')
			)
		})
		
		$table.css('min-width', '100%')
		$('td', $table).css({'padding': '4px', 'border-bottom': '1px solid #ebebeb'})
		$('td:first-of-type', $table).css('padding-left', '10px')
		$('tr.date_last td', $table).css('border-bottom', '2px solid #dadada')
		$('td.normal_header', $table).css('border-bottom', '1px solid #bebebe')
		
		$table.appendTo($content)
	}
	
})()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址