-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathEnlargeKiwifarmsProfilePictures.user.js
More file actions
143 lines (131 loc) · 4.64 KB
/
EnlargeKiwifarmsProfilePictures.user.js
File metadata and controls
143 lines (131 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// ==UserScript==
// @name Kiwifarms - Expand Avatars on Hover
// @namespace nick2bad4u.github.io
// @version 1.2.1
// @description Expand avatars on hover for Kiwifarms Users
// @author Nick2bad4u
// @match kiwifarms.com/*
// @match kiwifarms.net/*
// @match kiwifarms.ms/*
// @match kiwifarms.ru/*
// @match kiwifarms.is/*
// @match kiwifarms.top/*
// @match kiwifarms.tw/*
// @match kiwifarms.hk/*
// @match kiwifarms.nl/*
// @match sneed.today/*
// @match kiwifarms.pl/*
// @match kiwifarms.st/*
// @connect kiwifarms.st/*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @homepageURL https://github.com/Nick2bad4u/UserStyles
// @homepage https://github.com/Nick2bad4u/UserStyles
// @license Unlicense
// @resource https://www.google.com/s2/favicons?sz=64&domain=kiwifarms.st
// @icon https://www.google.com/s2/favicons?sz=64&domain=kiwifarms.st
// @icon64 https://www.google.com/s2/favicons?sz=64&domain=kiwifarms.st
// @tag kiwifarms
// @downloadURL https://update.greasyfork.org/scripts/525997/Kiwifarms%20-%20Expand%20Avatars%20on%20Hover.user.js
// @updateURL https://update.greasyfork.org/scripts/525997/Kiwifarms%20-%20Expand%20Avatars%20on%20Hover.meta.js
// ==/UserScript==
(function () {
'use strict';
// Default settings
const defaultSize = 400;
const defaultScale = 2;
let avatarSize = GM_getValue('avatarSize', defaultSize);
let avatarScale = GM_getValue('avatarScale', defaultScale);
// Add custom styles for the expanded avatar
const style = document.createElement('style');
style.textContent = `
.expanded-avatar {
position: absolute;
border: 2px solid #000;
border-radius: 50%;
max-width: ${avatarSize}px;
max-height: ${avatarSize}px;
z-index: 9999;
display: none;
transform: scale(${avatarScale});
}
`;
document.head.appendChild(style);
// Create an element to show the expanded avatar
const expandedAvatar = document.createElement('img');
expandedAvatar.className = 'expanded-avatar';
document.body.appendChild(expandedAvatar);
// Function to show the expanded avatar
function showExpandedAvatar(event) {
const avatar = event.target;
expandedAvatar.src = avatar.src;
expandedAvatar.style.left = `${event.pageX + 60}px`;
expandedAvatar.style.top = `${event.pageY + 60}px`;
expandedAvatar.style.display = 'block';
}
// Function to hide the expanded avatar
function hideExpandedAvatar() {
expandedAvatar.style.display = 'none';
}
// Attach event listeners to avatar images
document.querySelectorAll('.avatar img').forEach((avatar) => {
avatar.addEventListener('mouseover', showExpandedAvatar);
avatar.addEventListener('mouseout', hideExpandedAvatar);
});
// Update avatar position on mouse move
document.addEventListener('mousemove', (event) => {
if (expandedAvatar.style.display === 'block') {
expandedAvatar.style.left = `${event.pageX + 60}px`;
expandedAvatar.style.top = `${event.pageY + 60}px`;
}
});
// Function to set avatar size
function setAvatarSize() {
const size = prompt('Enter the avatar size (in pixels, max 400):', avatarSize);
if (size !== null) {
// Check if the input is a valid number and within the limit
const parsedSize = parseInt(size, 10);
if (!isNaN(parsedSize) && parsedSize > 0 && parsedSize <= 400) {
avatarSize = parsedSize;
GM_setValue('avatarSize', avatarSize);
updateStyle();
} else {
alert('Please enter a valid positive number up to 400 for avatar size.');
}
}
}
// Function to set avatar scale
function setAvatarScale() {
const scale = prompt('Enter the avatar scale (e.g., 2 for 200%):', avatarScale);
if (scale !== null) {
// Check if the input is a valid number
const parsedScale = parseFloat(scale);
if (!isNaN(parsedScale) && parsedScale > 0 && parsedScale <= 2) {
avatarScale = parsedScale;
GM_setValue('avatarScale', avatarScale);
updateStyle();
} else {
alert('Please enter a valid positive number for avatar scale.');
}
}
}
// Function to update the custom styles
function updateStyle() {
style.textContent = `
.expanded-avatar {
position: absolute;
border: 2px solid #000;
border-radius: 50%;
max-width: ${avatarSize}px;
max-height: ${avatarSize}px;
z-index: 9999;
display: none;
transform: scale(${avatarScale});
}
`;
}
// Register menu commands to set avatar size and scale
GM_registerMenuCommand('Set Avatar Hover Size', setAvatarSize);
GM_registerMenuCommand('Set Avatar Hover Scale', setAvatarScale);
})();