Weblock
Applock but for websites

Code Snippet

1// ==========================================
2// 🔒 WEBSITE APPLOCK SCRIPT (Ultra-Minimal)
3// ==========================================
4
5// Add the domains you want to lock down right here!
6const TARGET_DOMAINS = [
7    "youtube.com"
8];
9
10// Rely on the guaranteed selection context instead of async tabs
11const currentDomain = new URL(selection.pageUrl).hostname;
12
13// Check if the current domain matches (handles subdomains like www.youtube.com seamlessly)
14const shouldLock = TARGET_DOMAINS.some(domain => 
15    currentDomain === domain || currentDomain.endsWith("." + domain)
16);
17
18// If it's not a target site, exit immediately without doing anything
19if (!shouldLock) {
20    return;
21}
22
23// 1. Instantly paralyze and blur the page!
24const cssId = await page.injectCSS(`
25    html, body { overflow: hidden !important; }
26    body > * { 
27        filter: blur(25px) grayscale(100%) !important; 
28        pointer-events: none !important; 
29        user-select: none !important; 
30        opacity: 0.1 !important;
31    }
32    body { background: #000 !important; }
33`);
34
35try {
36    let masterPin = await storage.get("applock_pin");
37
38    // 2. FIRST-TIME SETUP
39    while (!masterPin) {
40        const setupPin = await input.prompt({ 
41            title: "Setup AppLock: Create a 4-digit PIN", 
42            placeholder: "••••",
43            position: "center" 
44        });
45        
46        // If they hit Esc or click outside, block them out permanently (until refresh)
47        if (setupPin === null || setupPin === undefined) {
48            return;
49        }
50        
51        if (setupPin.trim().length >= 4) {
52            masterPin = setupPin.trim();
53            await storage.set("applock_pin", masterPin);
54            break;
55        }
56    }
57
58    // 3. SNAPPY VERIFICATION LOOP
59    while (true) {
60        const enteredPin = await input.prompt({ 
61            title: `Unlock ${currentDomain}`, 
62            placeholder: "Enter PIN...",
63            position: "center"
64        });
65        
66        // If they hit Esc or click outside the unlock prompt, block them out permanently (until refresh)
67        if (enteredPin === null || enteredPin === undefined) {
68            return;
69        }
70        
71        if (enteredPin === masterPin) {
72            // Correct PIN! The loop breaks.
73            break;
74        }
75    }
76
77} finally {
78    // 4. Instantly strip the blur CSS when they unlock!
79    await page.removeCSS(cssId); 
80}
81
Submitted on 7/13/2026