MyAnimeList (MAL) Alternative History

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

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

// ==UserScript==
// @name         MyAnimeList (MAL) Alternative History
// @namespace    https://gf.qytechs.cn/users/7517
// @description  Displays anime/manga series history instead of episode/chapter history, based on RSS feed.
// @version      1.0.0
// @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 = new Array()
	
	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(/^(.+) - (\w+)$/)[1],
				type: $('title', this).text().match(/ - (\w+)$/)[1],
				link: $('link', this).text(),
				status: $('description', this).text().match(/^(\w+) - /)[1],
				progress: $('description', this).text().match(/ - (.+)$/)[1],
				date: new Date($('pubDate', this).text())
			}
			
			if (feedType === FEED_MANGA) {
				if (entry.status === 'Watching') {
					entry.status = 'Reading'
				}
			}
			
			entry.progress = entry.progress.replace(' episodes', '')
			entry.progress = entry.progress.replace(' chapters', '')
			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="new_content" style="padding: 0 15px 10px 15px;"></div>')
		$('#horiznav_nav + div').hide().before($content)
		
		var $table = $('<table id="new_history" border="0" cellpadding="0" cellspacing="0"></table>')
		
		$table.append($('<tr></tr>')
			.append('<td class="new_header" width="30">#</td>')
			.append('<td class="new_header">Title</td>')
			.append('<td class="new_header" width="50">Type</td>')
			.append('<td class="new_header" width="70">Status</td>')
			.append('<td class="new_header" width="70">Progress</td>')
			.append('<td class="new_header" width="125">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'
			})
			
			$table.append($('<tr></tr>')
				.append('<td width="30">' + (index + 1) + '</td>')
				.append($('<td></td>').append('<a href="' + entry.link + '">' + entry.title + '</a>'))
				.append('<td width="50">' + entry.type + '</td>')
				.append('<td width="70">' + entry.status + '</td>')
				.append('<td width="70">' + entry.progress + '</td>')
				.append('<td width="125">' + formatDate + '</td>')
			)
		})
		
		$table.css({'min-width': '100%', 'width': '100%'})
		$('td', $table).css({'padding': '4px', 'border-bottom': '1px solid #ebebeb', 'text-align': 'center'})
		$('td:nth-of-type(2)', $table).css('text-align', 'left')
		$('td.new_header', $table).css('font-weight', 'bold')
		
		$table.appendTo($content)
	}
	
})()

QingJ © 2025

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