Skip to content

Commit a074c54

Browse files
committed
feat(RightClickEnable): update version to 1.8 and enhance notification with drag functionality
1 parent 956afba commit a074c54

1 file changed

Lines changed: 105 additions & 4 deletions

File tree

RightClickEnable.user.js

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// ==UserScript==
22
// @name Allow Right-Click with Tampermonkey Menu Option
33
// @namespace typpi.online
4-
// @version 1.7
4+
// @version 1.8
55
// @description Allows right-clicking on websites that prevent it by clicking the menu button in the Tampermonkey extension.
66
// @author Nick2bad4u
77
// @match *://*/*
88
// @grant GM_registerMenuCommand
99
// @icon https://i.gyazo.com/353b60294e0dc77af7119d58ab0aa1ad.png
10-
// @updateURL https://github.com/Nick2bad4u/UserStyles/raw/refs/heads/main/RightCLickEnable.user.js
11-
// @downloadURL https://github.com/Nick2bad4u/UserStyles/raw/refs/heads/main/RightCLickEnable.user.js
10+
// @updateURL https://github.com/Nick2bad4u/UserStyles/raw/refs/heads/main/RightClickEnable.user.js
11+
// @downloadURL https://github.com/Nick2bad4u/UserStyles/raw/refs/heads/main/RightClickEnable.user.js
1212
// @license UnLicense
1313
// @tag all
1414
// ==/UserScript==
@@ -46,9 +46,110 @@
4646
true,
4747
);
4848

49-
alert('Right-click has been enabled!');
49+
// Create a non-blocking notification
50+
const notification = document.createElement('div');
51+
notification.textContent = 'Right-click has been enabled!';
52+
notification.style.position = 'fixed';
53+
notification.style.top = '10vh'; // Set to 10% of the viewport height for better consistency
54+
notification.style.left = '50%';
55+
notification.style.transform = 'translate(-50%, -50%)';
56+
notification.style.backgroundColor = '#4CAF50';
57+
notification.style.color = 'white';
58+
notification.style.padding = '20px';
59+
notification.style.fontSize = '18px';
60+
notification.style.borderRadius = '10px';
61+
notification.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.3)';
62+
notification.style.zIndex = '99999';
63+
notification.style.opacity = '0';
64+
notification.style.transition = 'opacity 0.5s ease, transform 0.5s ease, background-color 0.5s ease';
65+
notification.style.border = '2px solid black'; // Added black border
66+
notification.style.cursor = 'move'; // Indicate that the notification is draggable
67+
68+
// Add a tooltip for drag functionality
69+
notification.title = 'Drag to move this notification';
70+
document.body.appendChild(notification);
71+
72+
// Add an exit button
73+
const exitButton = document.createElement('button');
74+
exitButton.textContent = '×';
75+
exitButton.style.position = 'absolute';
76+
exitButton.style.top = '5px';
77+
exitButton.style.right = '10px';
78+
exitButton.style.background = 'transparent';
79+
exitButton.style.border = 'none';
80+
exitButton.style.color = 'white';
81+
exitButton.style.fontSize = '16px';
82+
exitButton.style.cursor = 'pointer';
83+
exitButton.addEventListener('click', () => {
84+
if (typeof colorInterval !== 'undefined') {
85+
clearInterval(colorInterval); // Clear the color interval
86+
}
87+
notification.style.opacity = '0';
88+
notification.style.transform = 'translate(-50%, -10%)';
89+
setTimeout(() => notification.remove(), 500);
90+
});
91+
notification.appendChild(exitButton);
92+
93+
// Make the notification draggable
94+
let isDragging = false;
95+
let offsetX = 0;
96+
let offsetY = 0;
97+
98+
notification.addEventListener('mousedown', (event) => {
99+
isDragging = true;
100+
offsetX = event.clientX - notification.getBoundingClientRect().left;
101+
offsetY = event.clientY - notification.getBoundingClientRect().top;
102+
notification.style.transition = 'none'; // Disable transition during drag
103+
});
104+
105+
document.addEventListener('mousemove', (event) => {
106+
if (isDragging) {
107+
notification.style.left = `${event.clientX - offsetX}px`;
108+
notification.style.top = `${event.clientY - offsetY}px`;
109+
notification.style.transform = 'none'; // Disable centering during drag
110+
}
111+
});
112+
113+
document.addEventListener('mouseup', () => {
114+
isDragging = false;
115+
notification.style.transition = 'opacity 0.5s ease, transform 0.5s ease, background-color 0.5s ease'; // Re-enable transition
116+
});
117+
118+
// Trigger the fade-in animation
119+
setTimeout(() => {
120+
notification.style.opacity = '1';
121+
}, 0);
122+
123+
// Change color every second
124+
let randomColors = Array.from({ length: 4 }, () => `hsl(${Math.floor(Math.random() * 360)}, 100%, 50%)`); // Generate random bright colors
125+
let colorIndex = 0;
126+
127+
let isNotificationActive = true; // Flag to track if the notification is active
128+
129+
let colorInterval = setInterval(() => {
130+
if (isNotificationActive && notification.style.opacity === '1') {
131+
// Only update color if visible and active
132+
colorIndex = (colorIndex + 1) % randomColors.length; // Cycle through colors
133+
notification.style.backgroundColor = randomColors[colorIndex];
134+
}
135+
}, 750); // Change color every 750ms
136+
137+
// Clear the interval when fading out
138+
setTimeout(() => {
139+
if (isNotificationActive) {
140+
clearInterval(colorInterval);
141+
isNotificationActive = false; // Mark as inactive
142+
if (notification.parentNode) { // Check if notification is still in the DOM
143+
notification.style.opacity = '0';
144+
notification.style.transform = 'translate(-50%, -10%)';
145+
setTimeout(() => notification.remove(), 500); // Remove after fade-out
146+
}
147+
}
148+
}, 3000); // Start fade-out after 3 seconds
50149
}
51150

52151
// Register the option in the Tampermonkey menu
152+
/* eslint-disable no-undef */
53153
GM_registerMenuCommand('Enable Right-Click', enableRightClick);
154+
/* eslint-enable no-undef */
54155
})();

0 commit comments

Comments
 (0)