SHARE
TWEET

is this legit?

a guest Sep 23rd, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //META { "name": "AvatarHover", "website": "https://inve1951.github.io/BetterDiscordStuff/" } *//
  2. global.AvatarHover = function () {
  3.   var AsyncKeystate, css, defaultSettings, getSettings, handleFocusLoss, handleKeyUpDown, handleMouseOverOut, hoverCard, lastTarget, makeInput, qualifier, settings, updateHoverCard, updateQualifier;
  4.  
  5.   class AvatarHover {
  6.     getName() {
  7.       return "Avatar Hover";
  8.     }
  9.  
  10.     getDescription() {
  11.       return "When hovering, resize the avatar. Use Ctrl / Ctrl+Shift.";
  12.     }
  13.  
  14.     getAuthor() {
  15.       return "noVaLue, square";
  16.     }
  17.  
  18.     getVersion() {
  19.       return "0.6.0";
  20.     }
  21.  
  22.     load() {
  23.       return window.SuperSecretSquareStuff != null ? window.SuperSecretSquareStuff : window.SuperSecretSquareStuff = new Promise(function (c, r) {
  24.         return require("request").get("https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/0circle.plugin.js", function (err, res, body) {
  25.           if (err || 200 !== (res != null ? res.statusCode : void 0)) {
  26.             return r(err != null ? err : res);
  27.           }
  28.           Object.defineProperties(window.SuperSecretSquareStuff, {
  29.             libLoaded: {
  30.               value: c
  31.             },
  32.             code: {
  33.               value: body
  34.             }
  35.           });
  36.           return (0, eval)(body);
  37.         });
  38.       });
  39.     }
  40.  
  41.     async start() {
  42.       var createElement;
  43.       ({ AsyncKeystate, createElement } = await SuperSecretSquareStuff);
  44.       getSettings();
  45.       updateQualifier();
  46.       BdApi.injectCSS("css-AvatarHover", css);
  47.       hoverCard = createElement("div", {
  48.         id: "AvatarHover"
  49.       });
  50.       document.addEventListener("keydown", handleKeyUpDown, true);
  51.       document.addEventListener("keyup", handleKeyUpDown, true);
  52.       document.addEventListener("mouseover", handleMouseOverOut, true);
  53.       document.addEventListener("mouseout", handleMouseOverOut, true);
  54.       return window.addEventListener("blur", handleFocusLoss, true);
  55.     }
  56.  
  57.     stop() {
  58.       document.removeEventListener("keydown", handleKeyUpDown, true);
  59.       document.removeEventListener("keyup", handleKeyUpDown, true);
  60.       document.removeEventListener("mouseover", handleMouseOverOut, true);
  61.       document.removeEventListener("mouseout", handleMouseOverOut, true);
  62.       window.removeEventListener("blur", handleFocusLoss, true);
  63.       hoverCard.remove();
  64.       return BdApi.clearCSS("css-AvatarHover");
  65.     }
  66.  
  67.     static updateSettings() {
  68.       var checked, i, len, name, ref, type, value;
  69.       ref = document.querySelectorAll("#settings_AvatarHover input");
  70.       for (i = 0, len = ref.length; i < len; i++) {
  71.         ({ name, type, value, checked } = ref[i]);
  72.         settings[name] = "checkbox" === type ? checked : value || defaultSettings[name];
  73.       }
  74.       bdPluginStorage.set("AvatarHover", "settings", settings);
  75.       return updateQualifier();
  76.     }
  77.  
  78.     getSettingsPanel() {
  79.       var k, v;
  80.       getSettings();
  81.       return `<div id="settings_AvatarHover">${function () {
  82.         var ref, results;
  83.         ref = {
  84.           avatarBackgroundColor: "Background color",
  85.           avatarBorderRadius: "Border radius",
  86.           avatarBorderSize: "Border size",
  87.           avatarBorderColor: "Border color",
  88.           spacer: null,
  89.           isShown: "Force-show avatar",
  90.           isLarge: "Force large avatar",
  91.           isHoverGuilds: "Guilds",
  92.           isHoverChannels: "Channels / DM users",
  93.           isHoverFriends: "Friends list",
  94.           isHoverChatMessages: "Chat messages",
  95.           isHoverChatUsers: "Chat users"
  96.         };
  97.         results = [];
  98.         for (k in ref) {
  99.           v = ref[k];
  100.           results.push(makeInput(k, v));
  101.         }
  102.         return results;
  103.       }().join("")}</div>`;
  104.     }
  105.  
  106.   };
  107.  
  108.   hoverCard = AsyncKeystate = null;
  109.  
  110.   qualifier = null;
  111.  
  112.   updateQualifier = function () {
  113.     return qualifier = [settings.isHoverGuilds ? ".icon-3o6xvg" : void 0, settings.isHoverChannels ? ".avatarDefault-35WC3R, .avatarSpeaking-1wJCNq, .channel .avatar-small" : void 0, settings.isHoverFriends ? "#friends .avatar-small, .activityFeed-28jde9 .image-33JSyf" : void 0, settings.isHoverChatMessages ? ".message-1PNnaP .image-33JSyf, .embedAuthorIcon--1zR3L" : void 0, settings.isHoverChatUsers ? ".membersWrap-2h-GB4 .image-33JSyf" : void 0].filter(function (s) {
  114.       return s != null;
  115.     }).join(", ");
  116.   };
  117.  
  118.   handleKeyUpDown = function ({ key }) {
  119.     if (key !== "Control" && key !== "Shift") {
  120.       return;
  121.     }
  122.     return updateHoverCard();
  123.   };
  124.  
  125.   handleFocusLoss = function () {
  126.     return updateHoverCard();
  127.   };
  128.  
  129.   handleMouseOverOut = function ({ type, target }) {
  130.     if (!target.matches(qualifier)) {
  131.       return;
  132.     }
  133.     return updateHoverCard("mouseover" === type && target);
  134.   };
  135.  
  136.   lastTarget = null;
  137.  
  138.   updateHoverCard = function (target = lastTarget) {
  139.     var boundsTarget, boundsWindow, isLarge, isShown, k, left, ref, size, top, v;
  140.     lastTarget = target;
  141.     isShown = settings.isShown || AsyncKeystate.key("Control");
  142.     isLarge = settings.isLarge || AsyncKeystate.key("Shift");
  143.     if (!(isShown && target)) {
  144.       return hoverCard.remove();
  145.     }
  146.     size = isLarge && 256 || 128;
  147.     boundsTarget = target.getBoundingClientRect();
  148.     boundsWindow = {
  149.       width: window.innerWidth,
  150.       height: window.innerHeight
  151.     };
  152.     left = Math.max(0, boundsTarget.left + (boundsTarget.width - size) / 2);
  153.     if (left + size > boundsWindow.width) {
  154.       left = boundsWindow.width - size;
  155.     }
  156.     top = size > boundsWindow.height ? (boundsWindow.height - size) / 2 : boundsTarget.bottom + size > boundsWindow.height ? boundsTarget.top - size : boundsTarget.bottom;
  157.     ref = {
  158.       backgroundColor: settings.avatarBackgroundColor,
  159.       backgroundImage: ("IMG" === target.tagName && target.src || getComputedStyle(target).backgroundImage).replace(/\?size=\d{3,4}/, `?size=${size}`),
  160.       borderColor: settings.avatarBorderColor,
  161.       borderRadius: settings.avatarBorderRadius,
  162.       borderWidth: settings.avatarBorderSize,
  163.       width: `${size}px`,
  164.       height: `${size}px`,
  165.       top: `${top}px`,
  166.       left: `${left}px`
  167.     };
  168.     for (k in ref) {
  169.       v = ref[k];
  170.       hoverCard.style[k] = v;
  171.     }
  172.     if ("none" === hoverCard.style.backgroundImage) {
  173.       return hoverCard.remove();
  174.     }
  175.     return document.body.appendChild(hoverCard);
  176.   };
  177.  
  178.   defaultSettings = {
  179.     avatarBackgroundColor: "#303336",
  180.     avatarBorderRadius: "4px",
  181.     avatarBorderSize: "1px",
  182.     avatarBorderColor: "black",
  183.     isShown: false,
  184.     isLarge: false,
  185.     isHoverGuilds: false,
  186.     isHoverChannels: true,
  187.     isHoverFriends: true,
  188.     isHoverChatMessages: true,
  189.     isHoverChatUsers: true
  190.   };
  191.  
  192.   settings = null;
  193.  
  194.   getSettings = function () {
  195.     var k, ref, results, v;
  196.     if (settings != null) {
  197.       return;
  198.     }
  199.     settings = (ref = bdPluginStorage.get("AvatarHover", "settings")) != null ? ref : {};
  200.     results = [];
  201.     for (k in defaultSettings) {
  202.       v = defaultSettings[k];
  203.       results.push(settings[k] != null ? settings[k] : settings[k] = v);
  204.     }
  205.     return results;
  206.   };
  207.  
  208.   makeInput = function (name, label) {
  209.     var _default, isCheckbox, type;
  210.     if (label == null) {
  211.       return "<br/>";
  212.     }
  213.     type = Boolean === defaultSettings[name].constructor && (isCheckbox = true) && "checkbox" || "text";
  214.     _default = isCheckbox ? settings[name] ? "checked" : "" : `placeholder="${defaultSettings[name]}" value="${settings[name]}"`;
  215.     return `<label><input type="${type}" name="${name}" ${_default} onChange="AvatarHover.updateSettings()"/> ${label}</label><br/>`;
  216.   };
  217.  
  218.   css = "#AvatarHover {\n  background-size: cover;\n  border-style: solid;\n  display: block;\n  pointer-events: none;\n  position: fixed;\n  z-index: 99999;\n}\n#settings_AvatarHover {\n  color: #87909C;\n}";
  219.  
  220.   return AvatarHover;
  221. }.call(this);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top