Advertisement
Guest User

Games Tiscali avatar changer

a guest
Feb 4th, 2018
1,834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Games.Tiscali avatar changer
  3. // @namespace   games.cz
  4. // @include     http://diskuse.tiscali.cz/games/*
  5. // @include     https://diskuse.tiscali.cz/games/*
  6. // @version     1
  7. // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // Default source of the image to replace the unwanted image. If the user's avatar_src below isn't defined, this value is used.
  12. // CZ: Výchozí zdroj obrázku, který nahradí nežádoucí obrázek. Pokud není uživatelova hodnota avatar_src dole vyplněna, tento obrázek je použit
  13. var defaultImageSource = 'https://i.imgur.com/xOghGxE.jpg';
  14.  
  15. // Define users by their username field. Fill in the avatar_src field for a custom avatar for this user.
  16. // CZ: Definuj uživatele v poli username. Pokud chceš, aby měl vlastní avatar, specifikuj jeho zdroj v avatar_src.
  17. var usersToFilter = {
  18.     "Vymáčknutý jebák" : {
  19.         "username" : "Vymáčknutý jebák",
  20.         "avatar_src" : "https://i.imgur.com/DPm2oCg.jpg",
  21.     },
  22.     "Mart9" : {
  23.         "username" : "Mart9",
  24.     },
  25.     //"JakýkolivNázev" : {
  26.     //    "username" : "Jméno",
  27.     //    "avatar_src" : "Zdroj obrázku",
  28.     //},
  29. }
  30.  
  31. function ChangeAvatars(avatarsToChange)
  32. {
  33.     console.log("Games.Tiscali avatar changer: changing user avatars");
  34.  
  35.     for (var key in avatarsToChange)
  36.     {
  37.         var user = avatarsToChange[key];
  38.          
  39.         // Find posts by given username.
  40.         // Username ids are defined in the head (hd) of the post, therefore the two .parent() calls to get the whole post.
  41.         $("span[id*='item-username']:contains('" + user["username"] + "')").parent().parent().each(
  42.             function(i, val) {
  43.                 console.log("Found a post from user " + user["username"]);
  44.                        
  45.                 // Select the image
  46.                 var userImg = $(this).find('.user-icon').first();
  47.                        
  48.                 // Change the image's source
  49.                 if ("avatar_src" in user) {
  50.                     userImg.attr('src', user["avatar_src"]);
  51.                 }
  52.                 else {
  53.                     userImg.attr('src', defaultImageSource);
  54.                 }
  55.             }
  56.         );
  57.     }
  58. }
  59.  
  60. ChangeAvatars(usersToFilter);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement