VoidLayoutDesigner

Design AniList profile layouts

  1. // ==UserScript==
  2. // @name VoidLayoutDesigner
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Design AniList profile layouts
  6. // @author voidnyan
  7. // @match https://anilist.co/*
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const profileUserName = "voidnyan";
  15. const refreshIntervalInSeconds = 1;
  16.  
  17. const banner = "";
  18. const pfp = "";
  19. const bio = "";
  20. const pinned = "";
  21. const colorRgb = "77, 199, 222";
  22.  
  23. async function replaceImages() {
  24. const bannerElement = document.querySelector(".banner");
  25. const pfpElement = document.querySelector("img.avatar");
  26. const pfpLinkElements = document.querySelectorAll(`a.avatar[href*="${profileUserName}"]`);
  27. const bioElement = document.querySelector(".about img");
  28. const pinnedElement = document.querySelector(".activity-text:has(.pinned) img");
  29. const link = document.querySelector(".page-content > .user");
  30.  
  31. if (colorRgb.length > 0) {
  32. link.style.setProperty("--color-blue", colorRgb);
  33. link.style.setProperty("--color-blue-dim", colorRgb);
  34. }
  35.  
  36. if (banner.length > 0) {
  37. bannerElement.style = `background-image: url("${banner}")`;
  38. }
  39.  
  40. if (pfp.length > 0) {
  41. pfpElement.src = pfp;
  42. for (const pfpLink of pfpLinkElements) {
  43. pfpLink.style = `background-image: url("${pfp}")`;
  44. }
  45. }
  46.  
  47. if (bioElement && bio.length > 0){
  48. bioElement.src = bio;
  49. }
  50. if (pinnedElement && pinned.length > 0) {
  51. pinnedElement.src = pinned;
  52.  
  53. }
  54. }
  55.  
  56. let currentPath = "";
  57. let tryCount = 0;
  58.  
  59. setInterval(() => {
  60. const path = window.location.pathname;
  61. if (path !== currentPath || tryCount < 3) {
  62. currentPath = path;
  63. if (path === `/user/${profileUserName}/`) {
  64. replaceImages();
  65. }
  66. }
  67. }, refreshIntervalInSeconds * 1000);
  68.  
  69. })();