0% found this document useful (0 votes)
16 views3 pages

Message

The document is a user script that creates a privacy curtain feature for web pages, activated by a keyboard shortcut (Ctrl + \) or after 30 seconds of user inactivity. It includes functionality to display a countdown timer for the curtain activation and ensures the script does not run on YouTube. The curtain smoothly transitions in and out, providing a visual privacy layer when triggered.

Uploaded by

danufa11.11.11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Message

The document is a user script that creates a privacy curtain feature for web pages, activated by a keyboard shortcut (Ctrl + \) or after 30 seconds of user inactivity. It includes functionality to display a countdown timer for the curtain activation and ensures the script does not run on YouTube. The curtain smoothly transitions in and out, providing a visual privacy layer when triggered.

Uploaded by

danufa11.11.11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// ==UserScript==

// @name Curtain
// @namespace [Link]
// @version 1.0
// @description Ctrl+\ and 30 sec idle activates curtain
// @author ferris
// @match *://*/*
// @grant none
// ==/UserScript==

(function () {
'use strict';

// Check if the current site is YouTube


const currentDomain = [Link];
if ([Link]('[Link]')) {
return; // Exit the script entirely if on YouTube
}

// Create the privacy curtain


const curtain = [Link]('div');
[Link] = 'privacy-curtain';
[Link] = `
position: fixed;
top: 0;
right: -100%; /* Start off-screen */
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0); /* Fully transparent initially */
z-index: 9999;
transition: right 0.5s ease-in-out, background-color 0.5s ease-in-out; /*
Smooth sliding and opacity transition */
`;

// Append the curtain to the body


[Link](curtain);

// Function to toggle the privacy curtain


function toggleCurtain() {
if ([Link] === '-100%' || [Link] === '') {
// Slide in and make fully black
[Link] = '0'; // Slide into view
setTimeout(() => {
[Link] = 'rgba(0, 0, 0, 1)'; // Gradually
become fully opaque
}, 10); // Small delay to allow sliding animation to start first
} else {
// Slide out and make transparent
[Link] = 'rgba(0, 0, 0, 0)'; // Gradually become
transparent
setTimeout(() => {
[Link] = '-100%'; // Slide out of view after
transparency transition
}, 500); // Match the duration of the CSS transition
}
}

// Add keyboard shortcut (Ctrl + \)


[Link]('keydown', (event) => {
if ([Link] && [Link] === '\\') {
[Link](); // Prevent any default behavior
toggleCurtain();
}
});

// Variables for inactivity detection


let inactivityTimer;
let countdownInterval; // Track the countdown interval
const inactivityTimeout = 30000; // 30 seconds
let lastActivityTime = [Link](); // Track the last user activity time

// Create the numeric timer display


const timerDisplay = [Link]('div');
[Link] = 'timer-display';
[Link] = `
position: fixed;
bottom: 20px;
left: 20px;
padding: 5px 10px;
background-color: rgba(0, 0, 0, 0.7);
color: white;
font-family: Arial, sans-serif;
font-size: 14px;
border-radius: 5px;
z-index: 10000;
display: none; /* Initially hidden */
`;
[Link](timerDisplay);

// Function to reset the inactivity timer


function resetInactivityTimer() {
const currentTime = [Link]();

// Only reset the timer if enough time has passed since the last activity
if (currentTime - lastActivityTime > 500) { // 500ms debounce threshold
clearTimeout(inactivityTimer); // Clear any existing timer
clearInterval(countdownInterval); // Clear any existing countdown
interval
lastActivityTime = currentTime; // Update the last activity time

[Link] = 'block'; // Show the timer display


updateNumericTimer(inactivityTimeout / 1000); // Reset the timer
display to 30 seconds

// Set a new timer


inactivityTimer = setTimeout(() => {
toggleCurtain(); // Activate the curtain after inactivity timeout
[Link] = 'none'; // Hide the timer display
}, inactivityTimeout);
}
}

// Function to update the numeric timer


function updateNumericTimer(seconds) {
let remainingTime = [Link](seconds); // Start with the total seconds
[Link] = `Curtain in: ${remainingTime}s`; // Display the
initial time
// Clear any existing countdown interval before starting a new one
clearInterval(countdownInterval);

countdownInterval = setInterval(() => {


remainingTime -= 1; // Decrease the remaining time by 1 second
if (remainingTime >= 0) {
[Link] = `Curtain in: ${remainingTime}s`; //
Update the display
} else {
clearInterval(countdownInterval); // Stop the countdown when time
reaches 0
}
}, 1000); // Update every 1 second
}

// Debounce user activity events


const debounceReset = () => {
resetInactivityTimer();
};

// Reset the timer on user activity


[Link]('mousemove', debounceReset);
[Link]('mousedown', debounceReset);
[Link]('keydown', debounceReset);
[Link]('scroll', debounceReset);

// Initialize the inactivity timer


resetInactivityTimer();
})();

You might also like