Advertisement
Guest User

Games Tiscali avatar & text changer

a guest
Feb 5th, 2018
1,832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Games.Tiscali avatar & text 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. // 05.02.2018
  12.  
  13. // Default source of the image to replace the unwanted image. If the user's avatar_src below isn't defined, this value is used. If set to false, no avatar change will occur.
  14. // 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.
  15. // Je-li hodnota true, avatary se změní; je-li false, změna avatarů neproběhne.
  16. var changeAvatars = true;
  17. var defaultImageSource = 'https://i.imgur.com/xOghGxE.jpg';
  18.  
  19. // Default text if no "text_content" field below is specified. If set to false, no text change will occur.
  20. // CZ: Výchozí text příspěvku. Hodnota true = texty se změní; hodnota false = texty se nezmění.
  21. var changeTexts = true;
  22. var defaultText = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam ligula pede, sagittis quis, interdum ultricies, scelerisque eu. Etiam neque. Maecenas libero. Phasellus faucibus molestie nisl. Morbi scelerisque luctus velit. In rutrum. Et harum quidem rerum facilis est et expedita distinctio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam ante.';
  23.  
  24. // Define users by their username field. Fill in the avatar_src field for a custom avatar for this user.
  25. // CZ: Definuj uživatele v poli username. Pokud chceš, aby měl vlastní avatar, specifikuj jeho zdroj v avatar_src.
  26. var usersToFilter = {
  27.     "Vymáčknutý jebák" : {
  28.         "username" : "Vymáčknutý jebák",
  29.         "avatar_src" : "https://i.imgur.com/DPm2oCg.jpg",
  30.         "text_content" : "Jsem Jebák a tohle je jen neškodné cvrlikání.",
  31.     },
  32.     //"JakýkolivNázev" : {
  33.     //    "username" : "Jméno",
  34.     //    "avatar_src" : "Zdroj obrázku",
  35.     //    "text_content : "Text, který se zobrazí jako příspěvek",
  36.     //},
  37. }
  38.  
  39. function ChangeAvatars(avatarsToChange)
  40. {
  41.     console.log("Games.Tiscali avatar changer: changing user avatars");
  42.  
  43.     for (var key in avatarsToChange)
  44.     {
  45.         var user = avatarsToChange[key];
  46.          
  47.         // Find posts by given username.
  48.         // Username ids are defined in the head (hd) of the post, therefore the two .parent() calls to get the whole post.
  49.         $("span[id*='item-username']:contains('" + user["username"] + "')").parent().parent().each(
  50.             function(i, val) {
  51.                 console.log("Found a post from user " + user["username"]);
  52.                        
  53.                 // Change the image's source
  54.                 if (changeAvatars) {
  55.                     var userImg = $(this).find('.user-icon').first();
  56.                        
  57.                     if ("avatar_src" in user) {
  58.                         userImg.attr('src', user["avatar_src"]);
  59.                     }
  60.                     else {
  61.                         userImg.attr('src', defaultImageSource);
  62.                     }
  63.                 }
  64.                
  65.                 // Change the text
  66.                 if (changeTexts) {
  67.                     var userText = $(this).find('.disc-smile').first();
  68.                     userText.empty();
  69.              
  70.                     if ("text_content" in user) {
  71.                         userText.text(user["text_content"]);
  72.                     }
  73.                     else {
  74.                         userText.text(defaultText);
  75.                     }
  76.                 }
  77.             }
  78.         );
  79.     }
  80. }
  81.  
  82. ChangeAvatars(usersToFilter);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement