Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name FA Favorite User Highlighter (Adam487)
- // @namespace FAUH
- // @include http://www.furaffinity.net/msg/submissions/
- // @include http://www.furaffinity.net/msg/others/
- // @include http://www.furaffinity.net/user/*
- // @version 1
- // @grant GM_setValue
- // @grant GM_getValue
- // ==/UserScript==
- var names = GM_getValue("names","adam487");
- if(names == undefined || names == "") //Failsafe to keep it from breaking if user removes all names
- names = "adam487"//Shameless self-promotion? Nah, it just needs a default value...
- names = names.split(" ");
- if(window.content.location.href.substr(0,32) == "http://www.furaffinity.net/user/")
- {
- var isUserPage = true;
- var user = window.content.location.href.slice(32,window.content.location.href.length-1);
- }
- //Get all links
- var links = document.getElementsByTagName("a");
- //*****JOURNAL AND SUBMISSIONS LIST*****
- for(i = 0; i < links.length; i++)
- {
- for(j=0;j<names.length;j++)
- {
- //If link contents match a name
- if(links[i].innerHTML.toLowerCase() == names[j].toLowerCase())
- {
- //Check journal list
- //Should find a less 'hard-coded' way to search for these things. This will break when(if?) FA changes
- if(links[i].parentNode.parentNode.parentNode.id == "messages-journals")
- {
- links[i].parentNode.style.color="yellow";
- var siblings = links[i].parentNode.getElementsByTagName("*");
- for(k=0;k<siblings.length;k++)
- {
- siblings[k].style.color="yellow";
- }
- }
- //Check submissions list
- if(links[i].parentNode.parentNode.parentNode.parentNode.parentNode.id == "messagecenter-submissions")
- {
- links[i].style.color="yellow";
- var image = links[i].parentNode.parentNode.childNodes[0].childNodes[0].childNodes[0].childNodes[0];
- image.style.border = "10px solid yellow";
- }
- }
- }
- }
- //User page "Favorite" Button
- var tab = document.getElementsByClassName("tab")[0];
- var newB = document.createElement('b');
- var newA = document.createElement('a');
- if(names.indexOf(user) > -1)
- {
- var linkText = document.createTextNode("-Favorite")
- var userIsInFavorites = true;
- }
- else
- {
- var linkText = document.createTextNode("+Favorite")
- var userIsInFavorites = false;
- }
- linkText.id = "FAFUAdd";
- newA.appendChild(linkText);
- newA.title = "+Favorite";
- newB.appendChild(newA);
- tab.appendChild(newB);
- newA.onclick = function(){
- if(userIsInFavorites)
- {
- userIsInFavorites = false;
- newA.innerHTML="+Favorite";
- names.splice(names.indexOf(user),1);
- GM_setValue("names",names.join(" "))
- }
- else
- {
- userIsInFavorites = true;
- newA.innerHTML="-Favorite";
- names.push(user);
- GM_setValue("names",names.join(" "))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment