claude-3-7-sonnet-20250219· Anthropic LMArena Human Preference 140K
Write userscript for 7daystodie.com and subdomains that will create local storage…
- User
Write userscript for 7daystodie.com and subdomains that will create local storage variable age_gate with value like {value: 125, expires: 1781644842000} where expires will be at least 24 hours in the future and this local storage variable will be created if it doesn't exist yet.
- Assistant
Here's a userscript for 7daystodie.com that creates and manages the age_gate local storage variable:
// ==UserScript== // @name 7DTD Age Gate Storage // @namespace http://tampermonkey.net/ // @version 1.0 // @description Creates age_gate local storage variable for 7daystodie.com // @author You // @match *://*.7daystodie.com/* // @match *://7daystodie.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // Check if age_gate exists in localStorage const ageGate = localStorage.getItem('age_gate'); if (!ageGate) { // Create new age_gate object const now = new Date(); // Set expiration to 24 hours from now const expires = now.getTime() + (24 * 60 * 60 * 1000); const ageGateObj = { value: 125, expires: expires }; // Save to localStorage localStorage.setItem('age_gate', JSON.stringify(ageGateObj)); console.log('Age gate created:', ageGateObj); } else { // Check if existing age_gate is expired try { const ageGateObj = JSON.parse(ageGate); const now = new Date().getTime(); if (!ageGateObj.expires || ageGateObj.expires < now) { // Update with new expiration const newExpires = now + (24 * 60 * 60 * 1000); const newAgeGateObj = { value: 125, expires: newExpires }; localStorage.setItem('age_gate', JSON.stringify(newAgeGateObj)); console.log('Age gate updated:', newAgeGateObj); } } catch (e) { // If parsing fails, create a new valid object const now = new Date(); const expires = now.getTime() + (24 * 60 * 60 * 1000); const ageGateObj = { value: 125, expires: expires }; localStorage.setItem('age_gate', JSON.stringify(ageGateObj)); console.log('Age gate reset:', ageGateObj); } } })();Would you like me to explain or break down the code?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.