Greasy Fork

Anime Planet v4 Cleanup

Some tweaks for Anime Planet v4 site layout, including a new-episode alert.

当前为 2014-07-19 提交的版本,查看 最新版本

// ==UserScript==
// @name        Anime Planet v4 Cleanup
// @namespace   http://localhost
// @include     http://www.anime-planet.com/users/*/anime*
// @version     2
// @grant       none
// @description Some tweaks for Anime Planet v4 site layout, including a new-episode alert.
// ==/UserScript==

//////////////////////////////////////////////
//This script offers some tweaks intended for customizing your 'anime' page at AP. 
//I reserve no rights. Do what you want.
//////////////////////////////////////////////
// <[Select the features you want with these settings:]>

//removes the big banner at the top
var removeBanner = true;
//if this is enabled then you can mouse-over your avatar without 
//the annoying 'Edit Avatar' thingy coming up.
var disableEditAvatarOnMouseover = true;
//I fucking hate forced social shit like this. Fuck you. Stop following me.
var removeFollwersDisplay = true;
//Removes the age/gender display thingy.
var removeUserStatusDisplay = true;
//Nothing really useful in the footer. Navigation stuff is all at the top.
var removeFooter = true;
//This is the main feature. The 'Avg' column is annoying as hell. (More
//forced social crap when I just want to store my stats...)
//This feature will replace the 'Avg' column with the 'New' column.
//Any entry marked as 'Watching' or 'Want to Watch' will be flagged in this
//column if there are unwatched eps available.
//In other words, if you've watched 3 eps and ep 4 comes out, the column
//will say "NEW!" for that show. (Or whatever you specify here.)
var replaceAvgColumnWithNewColumn = true;
var htmlForNoNewEps = ""; //shows when no new eps are available
var htmlForNewEps = "NEW!"; //shows when new eps are available
/////////////////////////////////////////////

var siteContainer = document.body.children[3];
var loggedInUserName = document.body.children[2].children[0].children[3].children[1].children[0].children[1].text.trim();
var viewedUserName = siteContainer.children[2].children[0].children[2].children[1].text;
var footerObj = document.body.children[4];
var bgImage = siteContainer.children[1];
var editAvatar = siteContainer.children[2].children[0].children[0].children[0];
var followers = siteContainer.children[2].children[1];
var userStatus = siteContainer.children[2].children[0].children[3].children[1];
var table = siteContainer.children[7];
var avgColHeadA = table.children[0].children[0].children[3];
var entries = table.children[1];

if(loggedInUserName == viewedUserName) {
  if(removeBanner) {bgImage.parentNode.removeChild(bgImage);}
  if(disableEditAvatarOnMouseover) {editAvatar.parentNode.removeChild(editAvatar);}
  if(removeFollwersDisplay) {followers.parentNode.removeChild(followers);}
  if(removeUserStatusDisplay) {userStatus.parentNode.removeChild(userStatus);}
  if(removeFooter) {footerObj.parentNode.removeChild(footerObj);}
  
  if(replaceAvgColumnWithNewColumn) {
    avgColHeadA.innerHTML = "<a>New</a>";
    for(var i = 0; i < entries.children.length; i++) {
      var entry = entries.children[i];
      var avgCell = entry.children[3];
      avgCell.innerHTML = htmlForNoNewEps;
      var clusterFuck = entry.children[4].children[0].children[0];
      var statusList = clusterFuck.children[2];
      var status = statusList.options[statusList.selectedIndex].value;
      if(status == 2 || status == 4) {
        var epList = clusterFuck.children[3];
        var maxEp = epList.length - 1;
        var curEp = epList.selectedIndex;
        if(curEp != maxEp) {
          avgCell.innerHTML = htmlForNewEps;
        }
      }
    }
  }
}