From 0aa936525abc74754bc51060f4ed3d9b82ac6d8b Mon Sep 17 00:00:00 2001 From: Lisa Milne Date: Mon, 18 Dec 2023 12:25:40 +1000 Subject: [PATCH] add a command to accept or reject cookies --- clite/user.js | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/clite/user.js b/clite/user.js index 7fdd125..39d5ddf 100644 --- a/clite/user.js +++ b/clite/user.js @@ -598,4 +598,109 @@ Options: return main(args); }); +clite.commands.load('cookie',function(args,env,io) { + var stdio = io.include('stdio'); + var stdlib = io.include('stdlib'); + var clite = io.include('clite'); + + var pw = null; + + function help() { + stdio.printf(` +cookie - set cookie options +Usage: login [OPTION] + +Options: +-? Print this help information +-a Accept all cookies and local storage +-r Reject all cookies and local storage +-c Check the current state of cookies +`); + } + + function checkState(str) { + if (str == 'no') { + clite.setcookiestate(false); + io.exit(0); + return; + } + if (str != 'yes') { + cookies(); + return; + } + + clite.setcookiestate(true); + + io.exit(0); + } + + function cookies() { + clite.cookienotice(); + + stdio.printf("Enter 'yes' to agree, or 'no' to cancel: "); + if (!stdio.read(io.stdin,checkState)) { + stdio.write(io.stderr,'internal error\n'); + io.exit(1); + } + } + + function main(args) { + let accept = false; + let reject = false; + let check = false; + for (var i=1; i