Created
October 1, 2015 01:07
-
-
Save not-inept/5d583e75a6d7c442ca22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MAL Highlighter | |
// @namespace drillbit.notinept.me | |
// @description Highlights MAL shows. | |
// @include http://myanimelist.net/* | |
// @include https://myanimelist.net/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
var getUserTitles = function(user) { | |
//request user list | |
var url = "http://myanimelist.net/malappinfo.php?status=all&u=" + user; | |
var xmlHttp = null; | |
xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open( "GET", url, false ); | |
xmlHttp.send( null ); | |
//console.log(xmlHttp.responseText); | |
xml = xmlHttp.responseText; | |
//parse xml to javascript object | |
titles = {}; | |
anchor = "<anime>"; | |
for (var i = xml.indexOf(anchor); i >= 0; i = xml.indexOf(anchor, i + 1)) { | |
//console.log(xml.substring(i+65,i+75)); | |
title = xml.substring(xml.indexOf("<series_title>",i)+14, xml.indexOf("</series_title>",i)); | |
status = xml.substring(xml.indexOf("<my_status>",i)+11, xml.indexOf("</my_status>",i)); | |
// 1/watching, 2/completed, 3/onhold, 4/dropped, 6/plantowatch | |
score = xml.substring(xml.indexOf("<my_score>",i)+10, xml.indexOf("</my_score>",i)); | |
titles[title] = { "title" : title, "status" : status, "score" : score }; | |
} | |
return titles; | |
} | |
var user = document.getElementsByClassName('profile-name')[0].innerHTML; | |
var titles = getUserTitles(user); | |
var onPage = document.getElementsByTagName('tbody')[0].children; | |
for (var i = 0; i < onPage.length; ++i) { | |
var text = onPage[i].innerHTML; | |
if (text) { | |
title = text.substring(text.indexOf("<strong>")+8, text.indexOf("</strong>")); | |
if (titles[title]) { | |
var status = titles[title]['status']; | |
color = "rgba(0,150,150,.4)"; // plantowatch/dropped/onhold | |
if (status == 1) { color = "rgba(0,0,200,.4)"; } //watching | |
else if (status == 2) { color = "rgba(0,200,0,.4)"; } //watched | |
onPage[i].style.backgroundColor = color; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment