Guest User

Untitled

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