Guest User

Untitled

a guest
Mar 3rd, 2015
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        FA Favorite User Highlighter
  3. // @namespace   FAUH
  4. // @include     http://www.furaffinity.net/msg/submissions/
  5. // @include     http://www.furaffinity.net/msg/others/
  6. // @include     http://www.furaffinity.net/user/*
  7. // @version     1
  8. // @grant       GM_setValue
  9. // @grant       GM_getValue
  10. // @grant       GM_deleteValue
  11. // ==/UserScript==
  12.  
  13.  
  14.                                                                    
  15. var names = GM_getValue("names","adam487");
  16. if(names == undefined || names == "") //Failsafe to keep it from breaking if user removes all names
  17.     names = "adam487"//Shameless self-promotion? Nah, it just needs a default value...
  18.    
  19. names = names.split(" ");
  20. if(window.content.location.href.substr(0,32) == "http://www.furaffinity.net/user/")
  21. {
  22.     var isUserPage = true;
  23.     var user = window.content.location.href.slice(32,window.content.location.href.length-1);
  24. }
  25.  
  26. //Get all links
  27. var links = document.getElementsByTagName("a");
  28.  
  29. //*****JOURNAL AND SUBMISSIONS LIST*****
  30. for(i = 0; i < links.length; i++)
  31. {
  32.     for(j=0;j<names.length;j++)
  33.     {
  34.         //If link contents match a name
  35.         if(links[i].innerHTML.toLowerCase() == names[j].toLowerCase())
  36.         {
  37.             //Check journal list
  38.             //Should find a less 'hard-coded' way to search for these things. This will break when(if?) FA changes
  39.             if(links[i].parentNode.parentNode.parentNode.id == "messages-journals")
  40.             {
  41.                 links[i].parentNode.style.color="yellow";
  42.                 var siblings = links[i].parentNode.getElementsByTagName("*");
  43.                 for(k=0;k<siblings.length;k++)
  44.                 {
  45.                     siblings[k].style.color="yellow";      
  46.                 }
  47.             }
  48.             //Check submissions list
  49.             if(links[i].parentNode.parentNode.parentNode.parentNode.parentNode.id == "messagecenter-submissions")
  50.             {
  51.                 links[i].style.color="yellow";
  52.                 var image = links[i].parentNode.parentNode.childNodes[0].childNodes[0].childNodes[0].childNodes[0];
  53.                 image.style.border = "10px solid yellow";
  54.             }
  55.         }
  56.     }
  57. }
  58.  
  59. //User page "Favorite" Button
  60. var tab = document.getElementsByClassName("tab")[0];
  61. var newB = document.createElement('b');
  62. var newA = document.createElement('a');
  63. if(names.indexOf(user) > -1)
  64. {
  65.     var linkText = document.createTextNode("-Favorite")
  66.     var userIsInFavorites = true;
  67. }
  68. else
  69. {
  70.     var linkText = document.createTextNode("+Favorite")
  71.     var userIsInFavorites = false;
  72. }
  73. linkText.id = "FAFUAdd";
  74. newA.appendChild(linkText);
  75. newA.title = "+Favorite";
  76. newB.appendChild(newA);
  77. tab.appendChild(newB);
  78.  
  79. newA.onclick = function(){
  80.     if(userIsInFavorites)
  81.     {
  82.         userIsInFavorites = false;
  83.         newA.innerHTML="+Favorite";
  84.         names.splice(names.indexOf(user),1);
  85.         GM_setValue("names",names.join(" "))
  86.     }
  87.     else
  88.     {
  89.         userIsInFavorites = true;
  90.         newA.innerHTML="-Favorite";
  91.         names.push(user);
  92.         GM_setValue("names",names.join(" "))
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment